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 Is The Dictionary Class?

Answer»

The DICTIONARY CLASS provides the CAPABILITY to store key-value PAIRS.

The Dictionary class provides the capability to store key-value pairs.

2.

What Is An Object's Lock And Which Object's Have Locks?

Answer»

An OBJECT's lock is a mechanism that is USED by multiple threads to obtain SYNCHRONIZED access to the object. A thread may execute a synchronized METHOD of an object only after it has acquired the object's lock.

All objects and CLASSES have locks. A class's lock is acquired on the class's Class object.

An object's lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a synchronized method of an object only after it has acquired the object's lock.

All objects and classes have locks. A class's lock is acquired on the class's Class object.

3.

What Is The Difference Between The String And Stringbuffer Classes?

Answer»

STRING OBJECTS are CONSTANTS. STRINGBUFFER objects are not constants.

String objects are constants. StringBuffer objects are not constants.

4.

What Are The High-level Thread States?

Answer»

The high-level THREAD STATES are ready, running, WAITING, and DEAD.

The high-level thread states are ready, running, waiting, and dead.

5.

What Is The Relationship Between The Canvas Class And The Graphics Class?

Answer»

A CANVAS object PROVIDES ACCESS to a GRAPHICS object via its PAINT() method.

A Canvas object provides access to a Graphics object via its paint() method.

6.

How Are Java Source Code Files Named?

Answer»

A Java source code file TAKES the name of a public CLASS or interface that is defined WITHIN the file. A source code file may CONTAIN at most one public class or interface. If a public class or interface is defined within a source code file, then the source code file must take the name of the public class or interface.

If no public class or interface is defined within a source code file, then the file must take on a name that is different than its classes and INTERFACES. Source code files use the .java extension.

A Java source code file takes the name of a public class or interface that is defined within the file. A source code file may contain at most one public class or interface. If a public class or interface is defined within a source code file, then the source code file must take the name of the public class or interface.

If no public class or interface is defined within a source code file, then the file must take on a name that is different than its classes and interfaces. Source code files use the .java extension.

7.

What Is The Purpose Of The Wait(), Notify(), And Notifyall() Methods?

Answer»

The WAIT(), notify(), and notifyAll() methods are USED to PROVIDE an efficient way for threads to wait for a shared resource. When a thread executes an OBJECT's wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the object's notify() or notifyAll() methods..

The wait(), notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource. When a thread executes an object's wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the object's notify() or notifyAll() methods..

8.

How Are Commas Used In The Intialization And Iteration Parts Of A For Statement?

Answer»

Commas are USED to separate MULTIPLE statements WITHIN the INITIALIZATION and ITERATION parts of a for statement.

Commas are used to separate multiple statements within the initialization and iteration parts of a for statement.

9.

Which Containers May Have A Menubar?

Answer»

Frame.

Frame.

10.

Name Two Subclasses Of The Textcomponent Class.

Answer»

TEXTFIELD and TEXTAREA.

TextField and TextArea.

11.

What Method Is Invoked To Cause An Object To Begin Executing As A Separate Thread?

Answer»

The start() METHOD of the Thread CLASS is invoked to CAUSE an OBJECT to begin executing as a separate thread.

The start() method of the Thread class is invoked to cause an object to begin executing as a separate thread.

12.

What Must A Class Do To Implement An Interface?

Answer»

It must PROVIDE all of the METHODS in the INTERFACE and identify the interface in its implements clause.

It must provide all of the methods in the interface and identify the interface in its implements clause.

13.

Can A Double Value Be Cast To A Byte?

Answer»

YES, a DOUBLE VALUE can be CAST to a BYTE.

Yes, a double value can be cast to a byte.

14.

Which Java Operator Is Right Associative?

Answer»

The = OPERATOR is RIGHT ASSOCIATIVE.

The = operator is right associative.

15.

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

Answer»

A PROGRAM's main() method takes an ARGUMENT of the STRING[] TYPE.

A program's main() method takes an argument of the String[] type.

16.

What Is The Purpose Of The Finally Clause Of A Try-catch-finally Statement?

Answer»

The finally CLAUSE is used to PROVIDE the CAPABILITY to execute code no MATTER whether or not an exception is thrown or caught.

The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught.

17.

How Many Times May An Object's Finalize() Method Be Invoked By The Garbage Collector?

Answer»

An OBJECT's FINALIZE() METHOD may only be INVOKED once by the garbage collector.

An object's finalize() method may only be invoked once by the garbage collector.

18.

What Is The Purpose Of The Runtime Class?

Answer»

The PURPOSE of the RUNTIME class is to provide access to the Java runtime SYSTEM.

The purpose of the Runtime class is to provide access to the Java runtime system.

19.

Which Container Method Is Used To Cause A Container To Be Laid Out And Redisplayed?

Answer»

VALIDATE() method is USED to cause a CONTAINER to be LAID out and REDISPLAYED.

validate() method is used to cause a container to be laid out and redisplayed.

20.

What Is The Gregoriancalendar Class?

Answer»

The GregorianCalendar class PROVIDES SUPPORT for TRADITIONAL Western CALENDARS.

The GregorianCalendar class provides support for traditional Western calendars.

21.

Name Three Subclasses Of The Component Class.

Answer»

Box.Filler, BUTTON, Canvas, CHECKBOX, CHOICE, Container, Label, LIST, SCROLLBAR, or TextComponent.

Box.Filler, Button, Canvas, Checkbox, Choice, Container, Label, List, Scrollbar, or TextComponent.

22.

What Is The Difference Between The Boolean & Operator And The && Operator?

Answer»

If an expression INVOLVING the Boolean & OPERATOR is evaluated, both operands are evaluated. Then the & operator is applied to the operand. When an expression involving the && operator is evaluated, the FIRST operand is evaluated.

If the first operand returns a value of true then the second operand is evaluated. The && operator is then applied to the first and second operands. If the first operand evaluates to false, the EVALUATION of the second operand is skipped.

If an expression involving the Boolean & operator is evaluated, both operands are evaluated. Then the & operator is applied to the operand. When an expression involving the && operator is evaluated, the first operand is evaluated.

If the first operand returns a value of true then the second operand is evaluated. The && operator is then applied to the first and second operands. If the first operand evaluates to false, the evaluation of the second operand is skipped.

23.

What Invokes A Thread's Run() Method?

Answer»

After a thread is STARTED, VIA its START() method or that of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.

After a thread is started, via its start() method or that of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.

24.

Which Class Is The Immediate Superclass Of The Menucomponent Class?

Answer»

Object.

Object.

25.

What Is The Purpose Of Finalization?

Answer»

The purpose of FINALIZATION is to GIVE an UNREACHABLE object the opportunity to PERFORM any cleanup processing before the object is garbage collected.

The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.

26.

What Is The Immediate Superclass Of Menu?

Answer»

MenuItem.

MenuItem.

27.

Can An Anonymous Class Be Declared As Implementing An Interface And Extending A Class?

Answer»

An ANONYMOUS class may IMPLEMENT an interface or EXTEND a SUPERCLASS, but may not be DECLARED to do both.

An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.

28.

When A Thread Is Created And Started, What Is Its Initial State?

Answer»

A THREAD is in the READY STATE after it has been CREATED and STARTED.

A thread is in the ready state after it has been created and started.

29.

What Class Is The Top Of The Awt Event Hierarchy?

Answer»

The java.AWT.AWTEvent CLASS is the highest-level class in the AWT event-class HIERARCHY.

The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy.

30.

What Is A Task's Priority And How Is It Used In Scheduling?

Answer»

A task's priority is an integer VALUE that identifies the relative ORDER in which it should be executed with RESPECT to other tasks. The SCHEDULER attempts to schedule higher priority tasks before lower priority tasks.

A task's priority is an integer value that identifies the relative order in which it should be executed with respect to other tasks. The scheduler attempts to schedule higher priority tasks before lower priority tasks.

31.

What Is The Difference Between A Menuitem And A Checkboxmenuitem?

Answer»

The CheckboxMenuItem class extends the MenuItem class to SUPPORT a menu ITEM that MAY be CHECKED or UNCHECKED.

The CheckboxMenuItem class extends the MenuItem class to support a menu item that may be checked or unchecked.

32.

What Is The Catch Or Declare Rule For Method Declarations?

Answer»

If a checked exception MAY be THROWN WITHIN the BODY of a method, the method must either catch the exception or declare it in its THROWS clause.

If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause.

33.

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

Answer»

The DEFAULT VALUE of an STRING TYPE is NULL.

The default value of an String type is null.

34.

When A Thread Blocks On I/o, What State Does It Enter?

Answer»

A THREAD ENTERS the WAITING STATE when it BLOCKS on I/O.

A thread enters the waiting state when it blocks on I/O.

35.

What Are Order Of Precedence And Associativity, And How Are They Used?

Answer»

Order of PRECEDENCE determines the order in which OPERATORS are evaluated in EXPRESSIONS.

Associatity determines whether an EXPRESSION is evaluated left-to-right or right-to-left.

Order of precedence determines the order in which operators are evaluated in expressions.

Associatity determines whether an expression is evaluated left-to-right or right-to-left.

36.

Can A For Statement Loop Indefinitely?

Answer»

YES, a for statement can loop indefinitely. For EXAMPLE, CONSIDER the following:
for(;;) ;

Yes, a for statement can loop indefinitely. For example, consider the following:
for(;;) ;

37.

What Is A Native Method?

Answer»

A NATIVE METHOD is a method that is IMPLEMENTED in a LANGUAGE other than JAVA.

A native method is a method that is implemented in a language other than Java.

38.

What Is Clipping?

Answer»

CLIPPING is the PROCESS of confining PAINT operations to a LIMITED area or SHAPE.

Clipping is the process of confining paint operations to a limited area or shape.

39.

What Is The Immediate Superclass Of The Dialog Class?

Answer»

Window.

Window.

40.

What Value Does Readline() Return When It Has Reached The End Of A File?

Answer»

The readLine() method returns null when it has REACHED the END of a FILE.

The readLine() method returns null when it has reached the end of a file.

41.

Name Three Component Subclasses That Support Painting.

Answer»

The Canvas, FRAME, Panel, and APPLET CLASSES SUPPORT painting.

The Canvas, Frame, Panel, and Applet classes support painting.

42.

What Is The Difference Between Preemptive Scheduling And Time Slicing?

Answer»

Under preemptive scheduling, the highest PRIORITY task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time SLICING, a task executes for a predefined slice of time and then reenters the POOL of ready TASKS.
The scheduler then determines which task should execute next, based on priority and other factors.

Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks.
The scheduler then determines which task should execute next, based on priority and other factors.

43.

What Is The Immediate Superclass Of The Applet Class?

Answer»

Panel.

Panel.

44.

Can An Object's Finalize() Method Be Invoked While It Is Reachable?

Answer»

An object's finalize() method cannot be INVOKED by the garbage collector while the object is STILL reachable. However, an object's finalize() method MAY be invoked by other objects.

An object's finalize() method cannot be invoked by the garbage collector while the object is still reachable. However, an object's finalize() method may be invoked by other objects.

45.

Does Garbage Collection Guarantee That A Program Will Not Run Out Of Memory?

Answer»

Garbage collection does not guarantee that a program will not run out of MEMORY. It is possible for programs to use up memory resources FASTER than they are garbage collected. It is also possible for programs to CREATE OBJECTS that are not subject to garbage collection.

Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.

46.

What Are Wrapped Classes?

Answer»

WRAPPED classes are classes that ALLOW PRIMITIVE TYPES to be accessed as objects.

Wrapped classes are classes that allow primitive types to be accessed as objects.

47.

Is Sizeof A Keyword?

Answer»

The SIZEOF OPERATOR is not a KEYWORD.

The sizeof operator is not a keyword.

48.

Which Java.util Classes And Interfaces Support Event Handling?

Answer»

The EventObject class and the EventListener INTERFACE SUPPORT event PROCESSING.

The EventObject class and the EventListener interface support event processing.

49.

What Is The Difference Between Yielding And Sleeping?

Answer»

When a task invokes its YIELD() METHOD, it RETURNS to the ready STATE. When a task invokes its SLEEP() method, it returns to the waiting state.

When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.

50.

Which Method Of The Component Class Is Used To Set The Position And Size Of A Component?

Answer»

setBounds() method is used to set the POSITION and SIZE of a COMPONENT.

setBounds() method is used to set the position and size of a component.