Explore topic-wise InterviewSolutions in Current Affairs.

This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.

1.

What Class Allows You To Read Objects Directly From A Stream?

Answer»

The ObjectInputStream CLASS supports the READING of OBJECTS from input STREAMS.

The ObjectInputStream class supports the reading of objects from input streams.

2.

What Class Of Exceptions Are Generated By The Java Run-time System?

Answer»

The Java RUNTIME system GENERATES RuntimeException and ERROR EXCEPTIONS.

The Java runtime system generates RuntimeException and Error exceptions.

3.

What Is The Difference Between A Choice And A List?

Answer»

A Choice is displayed in a compact form that requires you to pull it down to see the list of AVAILABLE choices. Only one item MAY be selected from a Choice.

A List may be displayed in such a way that SEVERAL List ITEMS are visible. A List supports the SELECTION of one or more List items.

A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected from a Choice.

A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List items.

4.

Name Four Container Classes.

Answer»

Window, Frame, Dialog, FileDialog, PANEL, APPLET, or SCROLLPANE.

Window, Frame, Dialog, FileDialog, Panel, Applet, or ScrollPane.

5.

What Is The Return Type Of A Program's Main() Method?

Answer»

A PROGRAM's MAIN() METHOD has a void return TYPE.

A program's main() method has a void return type.

6.

What Happens When You Invoke A Thread's Interrupt Method While It Is Sleeping Or Waiting?

Answer»

When a task's interrupt() method is executed, the task ENTERS the READY STATE. The NEXT time the task enters the RUNNING state, an InterruptedException is thrown.

When a task's interrupt() method is executed, the task enters the ready state. The next time the task enters the running state, an InterruptedException is thrown.

7.

How Can The Checkbox Class Be Used To Create A Radio Button?

Answer»

By ASSOCIATING CHECKBOX OBJECTS with a CheckboxGroup.

By associating Checkbox objects with a CheckboxGroup.

8.

If A Method Is Declared As Protected, Where May The Method Be Accessed?

Answer»

A protected METHOD may only be ACCESSED by classes or INTERFACES of the same package or by subclasses of the class in which it is declared.

A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

9.

Which Class Is The Immediate Superclass Of The Container Class?

Answer»

Component.

Component.

10.

When Is The Finally Clause Of A Try-catch-finally Statement Executed?

Answer»

The finally clause of the try-catch-finally statement is always executed unless the THREAD of EXECUTION TERMINATES or an EXCEPTION OCCURS within the execution of the finally clause.

The finally clause of the try-catch-finally statement is always executed unless the thread of execution terminates or an exception occurs within the execution of the finally clause.

11.

When Does The Compiler Supply A Default Constructor For A Class?

Answer»

The compiler supplies a default CONSTRUCTOR for a class if no other CONSTRUCTORS are provided.

The compiler supplies a default constructor for a class if no other constructors are provided.

12.

How Does Multithreading Take Place On A Computer With A Single Cpu?

Answer»

The operating system's task scheduler allocates EXECUTION time to multiple TASKS. By quickly SWITCHING between executing tasks, it creates the IMPRESSION that tasks EXECUTE sequentially.

The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.

13.

Which Math Method Is Used To Calculate The Absolute Value Of A Number?

Answer»

The ABS() METHOD is USED to calculate absolute values.

The abs() method is used to calculate absolute values.

14.

Can An Exception Be Rethrown?

Answer»

YES, an EXCEPTION can be rethrown.

Yes, an exception can be rethrown.

15.

What Is The Purpose Of The File Class?

Answer»

The FILE CLASS is used to CREATE objects that PROVIDE access to the files and directories of a local file system.

The File class is used to create objects that provide access to the files and directories of a local file system.

16.

What Is The Difference Between The Paint() And Repaint() Methods?

Answer»

The paint() method supports painting VIA a GRAPHICS object. The repaint() method is used to cause paint() to be INVOKED by the AWT painting THREAD.

The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread.

17.

What Is The Difference Between Static And Non-static Variables?

Answer»

A STATIC variable is associated with the CLASS as a whole rather than with SPECIFIC INSTANCES of a class.

Non-static variables take on unique values with each OBJECT instance.

A static variable is associated with the class as a whole rather than with specific instances of a class.

Non-static variables take on unique values with each object instance.

18.

What Modifiers Can Be Used With A Local Inner Class?

Answer»

A local INNER CLASS may be final or ABSTRACT.

A local inner class may be final or abstract.

19.

What Is The Collection Interface?

Answer»

The Collection INTERFACE PROVIDES support for the implementation of a mathematical bag - an UNORDERED collection of objects that may contain DUPLICATES.

The Collection interface provides support for the implementation of a mathematical bag - an unordered collection of objects that may contain duplicates.

20.

What Advantage Do Java's Layout Managers Provide Over Traditional Windowing Systems?

Answer»

Java USES layout managers to lay out COMPONENTS in a CONSISTENT manner across all windowing platforms. Since Java's layout managers aren't tied to absolute sizing and positioning, they are able to ACCOMODATE platform-specific DIFFERENCES among windowing systems.

Java uses layout managers to lay out components in a consistent manner across all windowing platforms. Since Java's layout managers aren't tied to absolute sizing and positioning, they are able to accomodate platform-specific differences among windowing systems.

21.

How Are The Elements Of A Gridbaglayout Organized?

Answer»

The ELEMENTS of a GridBagLayout are organized according to a grid. However, the elements are of different sizes and may occupy more than ONE ROW or COLUMN of the grid. In addition, the ROWS and columns may have different sizes.

The elements of a GridBagLayout are organized according to a grid. However, the elements are of different sizes and may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes.

22.

How Can A Gui Component Handle Its Own Events?

Answer»

A component can handle its own events by IMPLEMENTING the required EVENT-LISTENER INTERFACE and ADDING itself as its own event listener.

A component can handle its own events by implementing the required event-listener interface and adding itself as its own event listener.

23.

What Event Results From The Clicking Of A Button?

Answer»

The ActionEvent EVENT is GENERATED as the RESULT of the CLICKING of a button.

The ActionEvent event is generated as the result of the clicking of a button.

24.

What Is The Highest-level Event Class Of The Event-delegation Model?

Answer»

The java.util.EventObject CLASS is the highest-level class in the event-delegation class HIERARCHY.

The java.util.EventObject class is the highest-level class in the event-delegation class hierarchy.

25.

Is A Class A Subclass Of Itself?

Answer»

A CLASS is a SUBCLASS of itself.

A class is a subclass of itself.

26.

What Modifiers May Be Used With An Interface Declaration?

Answer»

An INTERFACE MAY be DECLARED as PUBLIC or ABSTRACT.

An interface may be declared as public or abstract.

27.

What Restrictions Are Placed On The Values Of Each Case Of A Switch Statement?

Answer»

During compilation, the values of each case of a switch STATEMENT MUST evaluate to a VALUE that can be PROMOTED to an INT value.

During compilation, the values of each case of a switch statement must evaluate to a value that can be promoted to an int value.

28.

What Is The Relationship Between An Event-listener Interface And An Event-adapter Class?

Answer»

An event-listener INTERFACE DEFINES the methods that MUST be implemented by an event handler for a PARTICULAR kind of event.

An event adapter provides a default implementation of an event-listener interface.

An event-listener interface defines the methods that must be implemented by an event handler for a particular kind of event.

An event adapter provides a default implementation of an event-listener interface.

29.

Is "abc" A Primitive Value?

Answer»

The STRING LITERAL "abc" is not a PRIMITIVE value. It is a String object.

The String literal "abc" is not a primitive value. It is a String object.

30.

What Is The Relationship Between Clipping And Repainting?

Answer»

When a WINDOW is repainted by the AWT painting thread, it SETS the CLIPPING regions to the area of the window that requires REPAINTING.

When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting.

31.

Which Class Should You Use To Obtain Design Information About An Object?

Answer»

The CLASS class is used to OBTAIN INFORMATION about an OBJECT's design.

The Class class is used to obtain information about an object's design.

32.

Name The Eight Primitive Java Types.

Answer»

The EIGHT PRIMITIVE types are byte, char, short, int, long, float, DOUBLE, and BOOLEAN.

The eight primitive types are byte, char, short, int, long, float, double, and boolean.

33.

Is &&= A Valid Java Operator?

Answer»

No. It is not a VALID JAVA OPERATOR.

No. It is not a valid java operator.

34.

How Are The Elements Of A Cardlayout Organized?

Answer»

The elements of a CardLayout are STACKED, one on top of the other, like a DECK of cards.

The elements of a CardLayout are stacked, one on top of the other, like a deck of cards.

35.

Which Textcomponent Method Is Used To Set A Textcomponent To The Read-only State?

Answer»

setEditable().

setEditable().

36.

What Is The Purpose Of The System Class?

Answer»

The purpose of the SYSTEM class is to provide ACCESS to system RESOURCES.

The purpose of the System class is to provide access to system resources.

37.

For Which Statements Does It Make Sense To Use A Label?

Answer»

The only statements for which it MAKES SENSE to use a label are those statements that can enclose a break or CONTINUE STATEMENT.

The only statements for which it makes sense to use a label are those statements that can enclose a break or continue statement.

38.

Does A Class Inherit The Constructors Of Its Superclass?

Answer»

A CLASS does not INHERIT CONSTRUCTORS from any of its superclasses.

A class does not inherit constructors from any of its superclasses.

39.

What Is The Map Interface?

Answer»

The Map INTERFACE replaces the JDK 1.1 Dictionary CLASS and is used ASSOCIATE keys with VALUES.

The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values.

40.

What Is The Simpletimezone Class?

Answer»

The SIMPLETIMEZONE class provides support for a GREGORIAN CALENDAR.

The SimpleTimeZone class provides support for a Gregorian calendar.

41.

If A Class Is Declared Without Any Access Modifiers, Where May The Class Be Accessed?

Answer»

A class that is declared without any access modifiers is said to have PACKAGE access. This MEANS that the class can only be ACCESSED by other classes and interfaces that are defined WITHIN the same package.

A class that is declared without any access modifiers is said to have package access. This means that the class can only be accessed by other classes and interfaces that are defined within the same package.

42.

What Classes Of Exceptions May Be Caught By A Catch Clause?

Answer»

A catch clause can catch any exception that may be assigned to the THROWABLE type. This INCLUDES the ERROR and Exception TYPES.

A catch clause can catch any exception that may be assigned to the Throwable type. This includes the Error and Exception types.

43.

What Is The Difference Between The Reader/writer Class Hierarchy And The Inputstream/outputstream Class Hierarchy?

Answer»

The Reader/Writer CLASS HIERARCHY is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.

The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.

44.

What Happens When A Thread Cannot Acquire A Lock On An Object?

Answer»

If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an OBJECT's LOCK, it ENTERS the waiting state until the lock BECOMES available.

If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an object's lock, it enters the waiting state until the lock becomes available.

45.

How Is Rounding Performed Under Integer Division?

Answer»

The FRACTIONAL part of the result is TRUNCATED. This is known as ROUNDING TOWARD zero.

The fractional part of the result is truncated. This is known as rounding toward zero.

46.

What Is The Difference Between The Font And Fontmetrics Classes?

Answer»

The FontMetrics CLASS is used to define implementation-specific properties, such as ascent and DESCENT, of a FONT OBJECT.

The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object.

47.

Is The Ternary Operator Written X : Y ? Z Or X ? Y : Z ?

Answer»

It is WRITTEN X ? y : Z.

It is written x ? y : z.

48.

Can An Object Be Garbage Collected While It Is Still Reachable?

Answer»

A reachable OBJECT cannot be garbage COLLECTED. Only UNREACHABLE objects MAY be garbage collected..

A reachable object cannot be garbage collected. Only unreachable objects may be garbage collected..

49.

What Is The Difference Between A Window And A Frame?

Answer»

The FRAME CLASS extends Window to define a main application window that can have a MENU bar.

The Frame class extends Window to define a main application window that can have a menu bar.

50.

How Are The Elements Of A Borderlayout Organized?

Answer»

The elements of a BorderLayout are ORGANIZED at the borders (North, South, EAST, and WEST) and the center of a CONTAINER.

The elements of a BorderLayout are organized at the borders (North, South, East, and West) and the center of a container.