InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
How Observer And Observable Used In Java Programming? |
|
Answer» OBJECTS that subclass the Observable class MAINTAIN a list of observers. When an Observable OBJECT is updated it invokes the update() METHOD of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects. Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects. |
|
| 2. |
Described Synchronization And Why Is It Important In Java Programming? |
|
Answer» With respect to multithreading, synchronization is the capability to CONTROL the access of multiple THREADS to shared RESOURCES. Without synchronization, it is possible for one thread to MODIFY a shared object while another thread is in the process of using or updating that object's value. This often causes dirty data and leads to SIGNIFICANT errors. With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value. This often causes dirty data and leads to significant errors. |
|
| 3. |
Described Synchronized Methods And Synchronized Statements In Java Programming? |
|
Answer» Synchronized methods are methods that are used to CONTROL ACCESS to an object. A thread only EXECUTES a synchronized method after it has acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. A synchronized STATEMENT can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement. Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement. |
|
| 4. |
Which Three Ways In Which A Thread Can Enter The Waiting State In Java Programming? |
|
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. |
|
| 5. |
Define Preferred Size Of A Component In Java Programming? |
|
Answer» The PREFERRED SIZE of a COMPONENT is the MINIMUM component size that will allow the component to DISPLAY normally. The preferred size of a component is the minimum component size that will allow the component to display normally. |
|
| 6. |
What's New With Stop(), Suspend() And Resume() Methods In Jdk 1.2? |
|
Answer» The stop(), SUSPEND() and RESUME() METHODS have been DEPRECATED in JDK 1.2. The stop(), suspend() and resume() methods have been deprecated in JDK 1.2. |
|
| 7. |
Described Transient Variable? |
|
Answer» A TRANSIENT VARIABLE is a variable that MAY not be SERIALIZED. A transient variable is a variable that may not be serialized. |
|
| 8. |
Which Containers Use Flowlayout As Their Default Layout In Java Programming? |
|
Answer» The PANEL and Applet CLASSES USE the FlowLayout as their default layout. The Panel and Applet classes use the FlowLayout as their default layout. |
|
| 9. |
Can A Lock Be Acquired On Class In Java Programming? |
|
Answer» YES, a LOCK can be ACQUIRED on a CLASS. This lock is acquired on the class's Class OBJECT. Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object. |
|
| 10. |
Define Llist Interface In Java Programming? |
|
Answer» The List INTERFACE provides SUPPORT for ORDERED COLLECTIONS of objects. The List interface provides support for ordered collections of objects. |
|
| 11. |
What Is Collections Api In Java Programming? |
|
Answer» The COLLECTIONS API is a set of classes and interfaces that SUPPORT operations on collections of OBJECTS. The Collections API is a set of classes and interfaces that support operations on collections of objects. |
|
| 12. |
Which State Does A Thread Enter When It Terminates Its Processing In Java Programming? |
|
Answer» When a THREAD terminates its PROCESSING, it enters the DEAD STATE. When a thread terminates its processing, it enters the dead state. |
|
| 13. |
Which Method Is Used To Specify A Container's Layout In Java Programming? |
|
Answer» The setLayout() method is used to SPECIFY a CONTAINER's layout in Java PROGRAMMING. The setLayout() method is used to specify a container's layout in Java Programming. |
|
| 14. |
Which Containers Is Use A Border Layout As Their Default Layout? |
|
Answer» The WINDOW, Frame and Dialog classes USE a border layout as their default layout in JAVA Programming. The window, Frame and Dialog classes use a border layout as their default layout in Java Programming. |
|
| 15. |
What Is Iterator Interface In Java Programming? |
|
Answer» The ITERATOR interface is used to step through the ELEMENTS of a COLLECTION. The Iterator interface is used to step through the elements of a Collection. |
|
| 16. |
Suppose If A Method Is Declared As Protected, Where May The Method Be Accessed In Java Programming? |
|
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. |
|
| 17. |
Which Modifiers May Be Used With An Inner Class That Is A Member Of An Outer Class In Java Programming? |
|
Answer» A (non-local) inner class may be declared as public, PROTECTED, PRIVATE, STATIC, FINAL, or abstract. A (non-local) inner class may be declared as public, protected, private, static, final, or abstract. |
|
| 18. |
What Is Vector Class In Java Programming? |
|
Answer» The Vector CLASS in JAVA Programming provides the capability to IMPLEMENT a growable ARRAY of objects. The Vector class in Java Programming provides the capability to implement a growable array of objects. |
|
| 19. |
Does Java Handle Integer Overflows And Underflows? |
|
Answer» It uses those low order BYTES of the result that can fit into the SIZE of the type allowed by the OPERATION. It uses those low order bytes of the result that can fit into the size of the type allowed by the operation. |
|
| 20. |
Described Wrapped Classes In Java Programming? |
|
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. |
|
| 21. |
Is The Size Of A Keyword In Java Programming? |
|
Answer» The SIZEOF OPERATOR is not a KEYWORD in JAVA PROGRAMMING. The sizeof operator is not a keyword in Java Programming. |
|
| 22. |
Can You Please Explain The Difference Between Yielding And Sleeping In Java Programming? |
|
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. |
|
| 23. |
How Many Bits Are Used To Represent The Unicode, Ascii, Utf-16, And Utf-8 Characters In Java Programming? |
|
Answer» Unicode requires 16 BITS and ASCII require 7 bits. ALTHOUGH the ASCII character SET uses only 7 bits, it is usually REPRESENTED as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns. Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns. |
|
| 24. |
How To Write A Loop Indefinitely In Java Programming? |
|
Answer» for(;;)-for LOOP; while(TRUE)-ALWAYS true, ETC. for(;;)-for loop; while(true)-always true, etc. |
|
| 25. |
Described Native Method In Java Programming? |
|
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. |
|
| 26. |
Which Component Subclasses That Support Painting In Java Programming? |
|
Answer» The CANVAS, Frame, Panel, and Applet CLASSES SUPPORT PAINTING. The Canvas, Frame, Panel, and Applet classes support painting. |
|
| 27. |
Which Class Is Superclass For Every Class In Java Programming? |
|
Answer» OBJECT class is the SUPERCLASS for every class in Java Programming. Object class is the superclass for every class in Java Programming. |
|
| 28. |
What Is Purpose Of Finalization In Java Programming? |
|
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. |
|
| 29. |
Can Anonymous Class Be Declared As Implementing An Interface And Extending A Class In Java Programming? |
|
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. |
|
| 30. |
Which Invokes A Thread's Run() Method In Java Programming? |
|
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. |
|
| 31. |
What Is Simpletimezone Class In Java Programming? |
|
Answer» The SIMPLETIMEZONE class provides SUPPORT for a Gregorian calendar in JAVA Programming. The SimpleTimeZone class provides support for a Gregorian calendar in Java Programming. |
|
| 32. |
Described Gregorian Calendar Class In Java Programming? |
|
Answer» The GregorianCalendar provides SUPPORT for TRADITIONAL Western CALENDARS in JAVA Programming. The GregorianCalendar provides support for traditional Western calendars in Java Programming. |
|
| 33. |
Described Properties Class In Java Programming? |
|
Answer» The properties class is a subclass of Hashtable that can be read from or written to a stream. It also PROVIDES the capability to specify a SET of DEFAULT values to be USED. The properties class is a subclass of Hashtable that can be read from or written to a stream. It also provides the capability to specify a set of default values to be used. |
|
| 34. |
Which Container Method Is Used To Cause Container To Be Laid Out And Redisplayed In Java Programming? |
|
Answer» VALIDATE(); : Container METHOD is used to cause a container to be laid out and REDISPLAYED in Java Programming. validate(); : Container method is used to cause a container to be laid out and redisplayed in Java Programming. |
|
| 35. |
Described The Purpose Of System Class In Java Programming? |
|
Answer» The purpose of the System CLASS is to provide ACCESS to system RESOURCES in JAVA Programming. The purpose of the System class is to provide access to system resources in Java Programming. |
|
| 36. |
What Is The Purpose Of Runtime Class In Java Programming? |
|
Answer» The PURPOSE of the RUNTIME class is to PROVIDE ACCESS to the JAVA runtime system in Java Programming. The purpose of the Runtime class is to provide access to the Java runtime system in Java Programming. |
|
| 37. |
Described Locale Class In Java Programming? |
|
Answer» The Locale CLASS is used to tailor PROGRAM output to the CONVENTIONS of a PARTICULAR geographic, political, or cultural region. The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region. |
|
| 38. |
What Is The Purpose Of Finally Clause Of A Try-catch-finally Statement In Java Programming? |
|
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. |
|
| 39. |
Described The Purpose Of The Wait(), Notify(), And Notifyall() Methods In Java Programming? |
|
Answer» The WAIT(),notify(), and NOTIFYALL() methods are used to provide an efficient way for THREADS to COMMUNICATE each other in Java Programming. The wait(),notify(), and notifyAll() methods are used to provide an efficient way for threads to communicate each other in Java Programming. |
|
| 40. |
What Must Class Do To Implement An Interface In Java Programming? |
|
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. |
|
| 41. |
What Are High-level Thread States In Java Programming? |
|
Answer» The high-level thread STATES are READY, RUNNING, waiting, and DEAD. The high-level thread states are ready, running, waiting, and dead. |
|
| 42. |
Described Abstract Method In Java Programming? |
|
Answer» An ABSTRACT method is a method WHOSE IMPLEMENTATION is deferred to a subclass in JAVA Programming. An abstract method is a method whose implementation is deferred to a subclass in Java Programming. |
|
| 43. |
Described Object's Lock And Which Object's Have Locks In Java Programming? |
|
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. |
|
| 44. |
Can You Please Explain The Difference Between Static And A Non-static Inner Class In Java Programming? |
|
Answer» A non-STATIC INNER class may have object instances that are ASSOCIATED with instances of the class's OUTER class. A static inner class does not have any object instances. A non-static inner class may have object instances that are associated with instances of the class's outer class. A static inner class does not have any object instances. |
|
| 45. |
Can You Please Explain The Difference Between Window And A Frame In Java Programming? |
|
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. |
|
| 46. |
When An Object Reference Be Cast To An Interface Reference In Java Programming? |
|
Answer» An OBJECT REFERENCE be CAST to an interface reference when the object implements the REFERENCED interface. An object reference be cast to an interface reference when the object implements the referenced interface. |
|
| 47. |
Which Package Has The Light Weight Components In Java Programming? |
|
Answer» javax.SWING package. All components in Swing, except JApplet, JDialog, JFrame and JWindow are lightweight components in JAVA PROGRAMMING. javax.Swing package. All components in Swing, except JApplet, JDialog, JFrame and JWindow are lightweight components in Java Programming. |
|
| 48. |
Can You Please Explain The Difference Between Font And Fontmetrics Classes In Java Programming? |
|
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. |
|
| 49. |
What Happens When A Thread Cannot Acquire Lock On An Object In Java Programming? |
|
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. |
|
| 50. |
Can You Please Explain The Difference Between Preemptive Scheduling And Time Slicing In Java Programming? |
|
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. |
|