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.

Which Component Subclass Is Used For Drawing And Painting?

Answer»

Canvas.

Canvas.

2.

What Methods Are Used To Get And Set The Text Label Displayed By A Button Object?

Answer»

getLabel() and setLabel().

getLabel() and setLabel().

3.

What Method Must Be Implemented By All Threads?

Answer»

All TASKS MUST implement the RUN() method, WHETHER they are a subclass of THREAD or implement the Runnable interface.

All tasks must implement the run() method, whether they are a subclass of Thread or implement the Runnable interface.

4.

When Is An Object Subject To Garbage Collection?

Answer»

An object is subject to GARBAGE collection when it becomes UNREACHABLE to the PROGRAM in which it is USED.

An object is subject to garbage collection when it becomes unreachable to the program in which it is used.

5.

Can An Unreachable Object Become Reachable Again?

Answer»

An unreachable object may BECOME REACHABLE again. This can happen when the object's finalize() METHOD is INVOKED and the object performs an operation which CAUSES it to become accessible to reachable objects.

An unreachable object may become reachable again. This can happen when the object's finalize() method is invoked and the object performs an operation which causes it to become accessible to reachable objects.

6.

How Does A Try Statement Determine Which Catch Clause Should Be Used To Handle An Exception?

Answer»

When an exception is thrown WITHIN the BODY of a try statement, the CATCH clauses of the try statement are examined in the order in which they appear. The first catch CLAUSE that is capable of handling the exception is executed. The remaining catch clauses are IGNORED.

When an exception is thrown within the body of a try statement, the catch clauses of the try statement are examined in the order in which they appear. The first catch clause that is capable of handling the exception is executed. The remaining catch clauses are ignored.

7.

What Are The Object And Class Classes Used For?

Answer»

The OBJECT class is the highest-level class in the Java class HIERARCHY. The Class class is used to represent the classes and INTERFACES that are LOADED by a Java PROGRAM..

The Object class is the highest-level class in the Java class hierarchy. The Class class is used to represent the classes and interfaces that are loaded by a Java program..

8.

What Modifiers May Be Used With A Top-level Class?

Answer»

A top-level CLASS MAY be PUBLIC, ABSTRACT, or FINAL.

A top-level class may be public, abstract, or final.

9.

What Is A Java Package And How Is It Used?

Answer»

A Java PACKAGE is a naming context for classes and interfaces. A package is used to create a SEPARATE name SPACE for groups of classes and interfaces.

Packages are also used to organize related classes and interfaces into a SINGLE API unit and to control accessibility to these classes and interfaces.

A Java package is a naming context for classes and interfaces. A package is used to create a separate name space for groups of classes and interfaces.

Packages are also used to organize related classes and interfaces into a single API unit and to control accessibility to these classes and interfaces.

10.

What Is The Purpose Of A Statement Block?

Answer»

A STATEMENT BLOCK is USED to ORGANIZE a sequence of STATEMENTS as a single statement group.

A statement block is used to organize a sequence of statements as a single statement group.

11.

What Is The Difference Between The Prefix And Postfix Forms Of The ++ Operator?

Answer»

The prefix form PERFORMS the INCREMENT operation and RETURNS the value of the increment operation.

The postfix form returns the CURRENT value all of the expression and then performs the increment operation on that value.

The prefix form performs the increment operation and returns the value of the increment operation.

The postfix form returns the current value all of the expression and then performs the increment operation on that value.

12.

Can Try Statements Be Nested?

Answer»

TRY STATEMENTS MAY be TESTED.

Try statements may be tested.

13.

To What Value Is A Variable Of The Boolean Type Automatically Initialized?

Answer»

The DEFAULT VALUE of the BOOLEAN TYPE is FALSE.

The default value of the boolean type is false.

14.

What Is The Difference Between A Public And A Non-public Class?

Answer»

A public CLASS MAY be accessed outside of its PACKAGE.

A non-public class may not be accessed outside of its package.

A public class may be accessed outside of its package.

A non-public class may not be accessed outside of its package.

15.

What Is The Difference Between A Scrollbar And A Scrollpane?

Answer»

A SCROLLBAR is a Component, but not a Container. A SCROLLPANE is a Container.

A ScrollPane handles its own EVENTS and performs its own SCROLLING.

A Scrollbar is a Component, but not a Container. A ScrollPane is a Container.

A ScrollPane handles its own events and performs its own scrolling.

16.

What Is Numeric Promotion?

Answer»

Numeric PROMOTION is the conversion of a smaller numeric type to a larger numeric type, so that integer and floating-point operations may take place. In numerical promotion, byte, char, and SHORT VALUES are converted to int values. The int values are also converted to LONG values, if necessary. The long and float values are converted to double values, as required.

Numeric promotion is the conversion of a smaller numeric type to a larger numeric type, so that integer and floating-point operations may take place. In numerical promotion, byte, char, and short values are converted to int values. The int values are also converted to long values, if necessary. The long and float values are converted to double values, as required.

17.

What Happens If A Try-catch-finally Statement Does Not Have A Catch Clause To Handle An Exception That Is Thrown Within The Body Of The Try Statement?

Answer»

The exception PROPAGATES up to the NEXT HIGHER level try-catch statement (if any) or results in the PROGRAM's TERMINATION.

The exception propagates up to the next higher level try-catch statement (if any) or results in the program's termination.

18.

What Is The Resourcebundle Class?

Answer»

The ResourceBundle CLASS is used to STORE LOCALE-specific resources that can be loaded by a PROGRAM to TAILOR the program's appearance to the particular locale in which it is being run.

The ResourceBundle class is used to store locale-specific resources that can be loaded by a program to tailor the program's appearance to the particular locale in which it is being run.

19.

Can An Abstract Class Be Final?

Answer»

An ABSTRACT CLASS MAY not be DECLARED as FINAL.

An abstract class may not be declared as final.

20.

What Are Three Ways In Which A Thread Can Enter The Waiting State?

Answer»

A THREAD can enter the waiting state by INVOKING its sleep() method, by blocking on I/O, by unsuccessfully attempting to acquire an object's LOCK, or by invoking an object's wait() method. It can ALSO enter the waiting state by invoking its (deprecated) SUSPEND() method.

A thread can enter the waiting state by invoking its sleep() method, by blocking on I/O, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method.

21.

Which Arithmetic Operations Can Result In The Throwing Of An Arithmeticexception?

Answer»

INTEGER / and % can RESULT in the THROWING of an ARITHMETICEXCEPTION.

Integer / and % can result in the throwing of an ArithmeticException.

22.

What Is A Layout Manager?

Answer»

ANSWER :A LAYOUT MANAGER is an object that is used to organize components in a CONTAINER.

23.

What Happens If An Exception Is Not Caught?

Answer»

An uncaught exception results in the uncaughtException() METHOD of the THREAD's ThreadGroup being INVOKED, which eventually results in the TERMINATION of the program in which it is THROWN.

An uncaught exception results in the uncaughtException() method of the thread's ThreadGroup being invoked, which eventually results in the termination of the program in which it is thrown.

24.

How Can A Dead Thread Be Restarted?

Answer»

A DEAD THREAD cannot be RESTARTED.

A dead thread cannot be restarted.

25.

What Restrictions Are Placed On Method Overriding?

Answer»

Overridden methods MUST have the same name, argument list, and RETURN type.

The overriding method may not LIMIT the ACCESS of the method it overrides.

The overriding method may not throw any EXCEPTIONS that may not be thrown by the overridden method.

Overridden methods must have the same name, argument list, and return type.

The overriding method may not limit the access of the method it overrides.

The overriding method may not throw any exceptions that may not be thrown by the overridden method.

26.

What Interface Is Extended By Awt Event Listeners?

Answer»

All AWT EVENT LISTENERS EXTEND the java.util.EventListener INTERFACE.

All AWT event listeners extend the java.util.EventListener interface.

27.

What Is A Compilation Unit?

Answer»

Answer :A COMPILATION unit is a JAVA SOURCE CODE file.

28.

How Are This And Super Used?

Answer»

this is used to REFER to the CURRENT object instance.

SUPER is used to refer to the VARIABLES and METHODS of the superclass of the current object instance.

this is used to refer to the current object instance.

super is used to refer to the variables and methods of the superclass of the current object instance.

29.

What Interface Must An Object Implement Before It Can Be Written To A Stream As An Object?

Answer»

An object must IMPLEMENT the Serializable or Externalizable INTERFACE before it can be written to a STREAM as an object.

An object must implement the Serializable or Externalizable interface before it can be written to a stream as an object.

30.

Which Package Is Always Imported By Default?

Answer»

The java.lang PACKAGE is ALWAYS IMPORTED by DEFAULT.

The java.lang package is always imported by default.

31.

What Is Your Platform's Default Character Encoding?

Answer»

If you are running Java on English Windows platforms, it is PROBABLY Cp1252. If you are running Java on English Solaris platforms, it is most LIKELY 8859_1.

If you are running Java on English Windows platforms, it is probably Cp1252. If you are running Java on English Solaris platforms, it is most likely 8859_1.

32.

What Happens When You Add A Double Value To A String?

Answer»

The RESULT is a STRING OBJECT.

The result is a String object.

33.

What Is The Difference Between The File And Randomaccessfile Classes?

Answer»

The FILE class ENCAPSULATES the files and DIRECTORIES of the LOCAL file SYSTEM.

The RandomAccessFile class provides the methods needed to directly access data contained in any part of a file.

The File class encapsulates the files and directories of the local file system.

The RandomAccessFile class provides the methods needed to directly access data contained in any part of a file.

34.

What Is The Purpose Of The Enableevents() Method?

Answer»

The ENABLEEVENTS() method is used to ENABLE an event for a particular OBJECT. Normally, an event is ENABLED when a listener is added to an object for a particular event.

The enableEvents() method is used by OBJECTS that handle events by overriding their event-dispatch methods.

The enableEvents() method is used to enable an event for a particular object. Normally, an event is enabled when a listener is added to an object for a particular event.

The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods.

35.

What Is A Void Return Type?

Answer»

A VOID RETURN TYPE indicates that a method does not return a VALUE.

A void return type indicates that a method does not return a value.

36.

Are True And False Keywords?

Answer»

The VALUES TRUE and FALSE are not KEYWORDS.

The values true and false are not keywords.

37.

What Are E And Pi?

Answer»

E is the base of the NATURAL LOGARITHM and PI is MATHEMATICAL value pi.

E is the base of the natural logarithm and PI is mathematical value pi.

38.

What Classes Of Exceptions May Be Thrown By A Throw Statement?

Answer»

A throw STATEMENT MAY throw any expression that may be ASSIGNED to the Throwable TYPE.

A throw statement may throw any expression that may be assigned to the Throwable type.

39.

What Is The Set Interface?

Answer»

The SET interface provides methods for ACCESSING the elements of a finite MATHEMATICAL set. SETS do not ALLOW duplicate elements.

The Set interface provides methods for accessing the elements of a finite mathematical set. Sets do not allow duplicate elements.

40.

If An Object Is Garbage Collected, Can It Become Reachable Again?

Answer»

Once an object is garbage COLLECTED, it ceases to EXIST. It can no LONGER become REACHABLE again.

Once an object is garbage collected, it ceases to exist. It can no longer become reachable again.

41.

What An I/o Filter?

Answer»

An I/O filter is an OBJECT that reads from one stream and WRITES to another, usually altering the DATA in some WAY as it is PASSED from one stream to another.

An I/O filter is an object that reads from one stream and writes to another, usually altering the data in some way as it is passed from one stream to another.

42.

What Are The Legal Operands Of The Instanceof Operator?

Answer»

The left OPERAND is an OBJECT reference or NULL value and the RIGHT operand is a class, interface, or array type.

The left operand is an object reference or null value and the right operand is a class, interface, or array type.

43.

What State Is A Thread In When It Is Executing?

Answer»

An EXECUTING THREAD is in the RUNNING STATE.

An executing thread is in the running state.

44.

What Checkbox Method Allows You To Tell If A Checkbox Is Checked?

Answer»

getState().

getState().

45.

Why Are The Methods Of The Math Class Static?

Answer»

So they can be INVOKED as if they are a MATHEMATICAL CODE LIBRARY.

So they can be invoked as if they are a mathematical code library.

46.

How Is It Possible For Two String Objects With Identical Values Not To Be Equal Under The == Operator?

Answer»

The == operator compares two OBJECTS to determine if they are the same object in MEMORY. It is POSSIBLE for two STRING objects to have the same value, but located indifferent areas of memory.

The == operator compares two objects to determine if they are the same object in memory. It is possible for two String objects to have the same value, but located indifferent areas of memory.

47.

What Is The Difference Between The Jdk 1.02 Event Model And The Event-delegation Model Introduced With Jdk 1.1?

Answer»

The JDK 1.02 EVENT model uses an event inheritance or bubbling approach. In this model, components are REQUIRED to handle their own events. If they do not handle a particular event, the event is inherited by (or bubbled up to) the component's container. The container then either handles the event or it is bubbled up to its container and so on, until the highest-level container has been tried.

In the event-delegation model, SPECIFIC objects are designated as event handlers for GUI components. These objects implement event-listener interfaces. The event-delegation model is more efficient than the event-inheritance model because it ELIMINATES the processing required to support the bubbling of unhandled events.

The JDK 1.02 event model uses an event inheritance or bubbling approach. In this model, components are required to handle their own events. If they do not handle a particular event, the event is inherited by (or bubbled up to) the component's container. The container then either handles the event or it is bubbled up to its container and so on, until the highest-level container has been tried.

In the event-delegation model, specific objects are designated as event handlers for GUI components. These objects implement event-listener interfaces. The event-delegation model is more efficient than the event-inheritance model because it eliminates the processing required to support the bubbling of unhandled events.

48.

What Is The Relationship Between A Method's Throws Clause And The Exceptions That Can Be Thrown During The Method's Execution?

Answer»

A method's THROWS clause must DECLARE any CHECKED exceptions that are not CAUGHT within the body of the method.

A method's throws clause must declare any checked exceptions that are not caught within the body of the method.

49.

Under What Conditions Is An Object's Finalize() Method Invoked By The Garbage Collector?

Answer»

The garbage COLLECTOR INVOKES an OBJECT's finalize() METHOD when it detects that the object has BECOME unreachable.

The garbage collector invokes an object's finalize() method when it detects that the object has become unreachable.

50.

What Is The Difference Between A Field Variable And A Local Variable?

Answer»

A field VARIABLE is a variable that is DECLARED as a member of a CLASS.

A LOCAL variable is a variable that is declared local to a method.

A field variable is a variable that is declared as a member of a class.

A local variable is a variable that is declared local to a method.