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. |
Explain The Concept Of Hashtables? |
|
Answer» A hashtable is a data structure that lets you look up stored items USING an associated KEY. With an array, you can quickly access an element by specifying an integer index. The limitation of an array is that the look up key can only be an integer. With a hashtable, on the other hand, you can associate an item with a key and then USE the key to look up the item. You can use an object of any type as a key in a hashtable. For example: you MIGHT specify the license-plate number as the key and use the key to look up the vehicle owner's record. To distinguish one item from the next, the associated key that you use must be unique for each item, as in the case of a vehicle's license plate number. A hashtable is a data structure that lets you look up stored items using an associated key. With an array, you can quickly access an element by specifying an integer index. The limitation of an array is that the look up key can only be an integer. With a hashtable, on the other hand, you can associate an item with a key and then use the key to look up the item. You can use an object of any type as a key in a hashtable. For example: you might specify the license-plate number as the key and use the key to look up the vehicle owner's record. To distinguish one item from the next, the associated key that you use must be unique for each item, as in the case of a vehicle's license plate number. |
|
| 2. |
How To Handle A Web Browser Resize Operation? |
|
Answer» You KNOW how important it is to suspend your threads when Java calls an APPLET's stop method. Normally, Java calls the stop method when a browser leaves the corresponding Web page. However, in some cases, a Web browser will unexpectedly call an applet's stop method. When a browser window is resized, the browser may first call the stop method and then the START method. If you only stop a thread when its applet stops and create a new thread when the applet restarts, the applet will probably not behave the way that a user expects. To prevent unwanted behavior after RESIZING the browser, your PROGRAM should suspend threads when the applet stops and resume the threads when the applet starts. You know how important it is to suspend your threads when Java calls an applet's stop method. Normally, Java calls the stop method when a browser leaves the corresponding Web page. However, in some cases, a Web browser will unexpectedly call an applet's stop method. When a browser window is resized, the browser may first call the stop method and then the start method. If you only stop a thread when its applet stops and create a new thread when the applet restarts, the applet will probably not behave the way that a user expects. To prevent unwanted behavior after resizing the browser, your program should suspend threads when the applet stops and resume the threads when the applet starts. |
|
| 3. |
What Is The Difference Between Yield() And Sleep()? |
|
Answer» When a object INVOKES yield() it returns to ready STATE. But when an object invokes SLEEP() method ENTERS to not ready state. When a object invokes yield() it returns to ready state. But when an object invokes sleep() method enters to not ready state. |
|
| 4. |
What Is The Difference Between Set And List? |
|
Answer» Set stores elements in an unordered WAY but does not contain DUPLICATE elements, where as LIST stores elements in an ordered way but MAY contain duplicate elements. Set stores elements in an unordered way but does not contain duplicate elements, where as list stores elements in an ordered way but may contain duplicate elements. |
|
| 5. |
Which Containers Use A Flow Layout As Their Default Layout? |
|
Answer» Panel and APPLET classes USE the FlowLayout as their DEFAULT LAYOUT. Panel and Applet classes use the FlowLayout as their default layout. |
|
| 6. |
What Is The Difference Between Scrollbar And Scrollpane? |
|
Answer» A Scrollbar is a COMPONENT, but not a Container whereas SCROLLPANE is a Container and HANDLES its own events and perform its own scrolling. A Scrollbar is a Component, but not a Container whereas Scrollpane is a Container and handles its own events and perform its own scrolling. |
|
| 7. |
What Are Controls And Their Different Types In Awt? |
|
Answer» CONTROLS are components that allow a user to interact with your application and the AWT supports the following types of controls: Labels, Push Buttons, CHECK Boxes, Choice LISTS, Lists, Scrollbars, Text Components. These controls are the SUBCLASSES of the Component. Controls are components that allow a user to interact with your application and the AWT supports the following types of controls: Labels, Push Buttons, Check Boxes, Choice Lists, Lists, Scrollbars, Text Components. These controls are the subclasses of the Component. |
|
| 8. |
What Is The Intersection And Union Methods? |
|
Answer» When your program uses Rectangle objects, you MAY NEED to determine the screen region that holds both objects or two Rectangle objects intersect, to find the intersection or the union of two rectangles, you can use the Rectangle class intersection and union methods. The intersection method returns the area where two Rectangle objects overlap. That is, the intersecting method return the area that two Rectangle objects have in common. The union method, on the other hand, behaves differently than you might EXPECT. The union method returns the smallest rectangle that encloses two Rectangle objects, INSTEAD of returning just the area covered by both objects. This illustrates the behavior of the intersection and union methods. When your program uses Rectangle objects, you may need to determine the screen region that holds both objects or two Rectangle objects intersect, to find the intersection or the union of two rectangles, you can use the Rectangle class intersection and union methods. The intersection method returns the area where two Rectangle objects overlap. That is, the intersecting method return the area that two Rectangle objects have in common. The union method, on the other hand, behaves differently than you might expect. The union method returns the smallest rectangle that encloses two Rectangle objects, instead of returning just the area covered by both objects. This illustrates the behavior of the intersection and union methods. |
|
| 9. |
What Are Keyboard Events? |
|
Answer» When Java generates a keyboard event, it passes an Event object that contains information about the key pressed, Java recognizes normal keys, MODIFIER keys, and special keys, For normal keys, the event object contains the key's ASCII value. For the function, ARROW and other special keys, there are no ASCII codes, so Java uses special Java-defined CODE. You have learned how to detect modifier keys. The modifier keys are STORED in the modifiers variable in the Event object. When Java generates a keyboard event, it passes an Event object that contains information about the key pressed, Java recognizes normal keys, modifier keys, and special keys, For normal keys, the event object contains the key's ASCII value. For the function, arrow and other special keys, there are no ASCII codes, so Java uses special Java-defined code. You have learned how to detect modifier keys. The modifier keys are stored in the modifiers variable in the Event object. |
|
| 10. |
What Do You Understand By Final Value? |
|
Answer» FINAL for a variable: VALUE is CONSTANT. FINAL for a METHOD: cannot be overridden. FINAL for a class: cannot be DERIVED. FINAL for a variable: value is constant. FINAL for a method: cannot be overridden. FINAL for a class: cannot be derived. |
|
| 11. |
What Do You Understand By Downcasting? |
|
Answer» The PROCESS of Downcasting refers to the CASTING from a general to a more specific TYPE, i.e; casting down the HIERARCHY. The process of Downcasting refers to the casting from a general to a more specific type, i.e; casting down the hierarchy. |
|
| 12. |
What Are The Types Of Casting? |
|
Answer» There are two types of CASTING in Java, these are IMPLICIT casting and EXPLICIT casting. There are two types of casting in Java, these are Implicit casting and Explicit casting. |
|
| 13. |
What Do You Understand By Casting In Java Language? |
|
Answer» The process of CONVERTING one DATATYPE to another in Java language is CALLED Casting. The process of converting one datatype to another in Java language is called Casting. |
|
| 14. |
What Is The Use Of Object And Class Classes? |
|
Answer» The Object class is the superclass of all other classes and it is highest-level class in the Java class hierarchy. Instances of the class Class represent classes and interfaces in a running Java APPLICATION. Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same ELEMENT type and number of dimensions. The primitive Java types (boolean, BYTE, char, short, int, long, FLOAT and double) and the keyword VOID are also represented as Class objects. The Object class is the superclass of all other classes and it is highest-level class in the Java class hierarchy. Instances of the class Class represent classes and interfaces in a running Java application. Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same element type and number of dimensions. The primitive Java types (boolean, byte, char, short, int, long, float and double) and the keyword void are also represented as Class objects. |
|
| 15. |
Differentiate Between A Class And An Object. |
|
Answer» A Class is only the definition or prototype of REAL life object. Whereas an object is an INSTANCE or living REPRESENTATION of real life object. Every object belongs to a class and every class contains one or more RELATED OBJECTS. A Class is only the definition or prototype of real life object. Whereas an object is an instance or living representation of real life object. Every object belongs to a class and every class contains one or more related objects. |
|
| 16. |
What Do You Understand By Numeric Promotion? |
|
Answer» The 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 the numerical promotion process the 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. The 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 the numerical promotion process the 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 Do You Understand By A Variable? |
|
Answer» The variables PLAY a very important role in computer programming. Variables enable programmers to write flexible programs. It is a MEMORY location that has been named so that it can be easily be referred to in the program. The variable is used to HOLD the data and it can be changed during the course of the EXECUTION of the program. The variables play a very important role in computer programming. Variables enable programmers to write flexible programs. It is a memory location that has been named so that it can be easily be referred to in the program. The variable is used to hold the data and it can be changed during the course of the execution of the program. |
|
| 18. |
What Are Access Specifiers Available In Java? |
|
Answer» Access SPECIFIERS are KEYWORDS that determine the TYPE of access to the member of a class. These are:
Access specifiers are keywords that determine the type of access to the member of a class. These are: |
|
| 19. |
Explain The Different Forms Of Polymorphism? |
|
Answer» From a practical programming VIEWPOINT, polymorphism exists in THREE distinct forms in Java:
From a practical programming viewpoint, polymorphism exists in three distinct forms in Java: |
|
| 20. |
Explain The Polymorphism Principle? |
|
Answer» The meaning of POLYMORPHISM is something like one name, many forms. Polymorphism enables one ENTITY to be used as a general category for different types of actions. The specific action is determined by the exact nature of the SITUATION. The concept of polymorphism can be EXPLAINED as "one interface, multiple METHODS". The meaning of Polymorphism is something like one name, many forms. Polymorphism enables one entity to be used as a general category for different types of actions. The specific action is determined by the exact nature of the situation. The concept of polymorphism can be explained as "one interface, multiple methods". |
|
| 21. |
How To Define An Interface? |
|
Answer» In Java, Interface defines the methods but does not IMPLEMENT them. Interface can INCLUDE constants. A class that implements the INTERFACES is bound to implement all the methods DEFINED in Interface. In Java, Interface defines the methods but does not implement them. Interface can include constants. A class that implements the interfaces is bound to implement all the methods defined in Interface. |
|
| 22. |
How To Define An Abstract Class? |
|
Answer» A class containing ABSTRACT method is called Abstract class. An Abstract class can't be instantiated. A class containing abstract method is called Abstract class. An Abstract class can't be instantiated. |
|
| 23. |
Explain The Inheritance Principle? |
|
Answer» Inheritance is the process by which ONE OBJECT acquires the PROPERTIES of ANOTHER object. Inheritance is the process by which one object acquires the properties of another object. |
|
| 24. |
Explain The Encapsulation Principle? |
|
Answer» Encapsulation is a process of binding or wrapping the DATA and the codes that OPERATES on the data into a single entity. This keeps the data safe from outside interface and misuse. One way to think about encapsulation is as a PROTECTIVE wrapper that prevents code and data from being arbitrarily ACCESSED by the other code defined outside the wrapper. Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by the other code defined outside the wrapper. |
|
| 25. |
Describe The Principles Of Oops? |
|
Answer» There are three MAIN PRINCIPALS of OOPS which are CALLED Polymorphism, INHERITANCE and Encapsulation. There are three main principals of oops which are called Polymorphism, Inheritance and Encapsulation. |
|
| 26. |
How You Can Force The Garbage Collection? |
|
Answer» Garbage COLLECTION is an AUTOMATIC PROCESS and can't be FORCED. Garbage collection is an automatic process and can't be forced. |
|
| 27. |
Is Iterator A Class Or Interface? What Is Its Use? |
|
Answer» ITERATOR is an INTERFACE which is used to step through the elements of a COLLECTION. Iterator is an interface which is used to step through the elements of a Collection. |
|
| 28. |
What Advantage Do Java's Layout Managers Provide Over Traditional Windowing Systems? |
|
Answer» JAVA uses layout MANAGERS to layout 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 accommodate platform-specific DIFFERENCES among windowing systems. Java uses layout managers to layout 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 accommodate platform-specific differences among windowing systems. |
|
| 29. |
Name Primitive Java Types? |
|
Answer» The primitive JAVA types are BYTE, CHAR, short, int, LONG, float, double and boolean. The primitive Java types are byte, char, short, int, long, float, double and boolean. |
|
| 30. |
What Is The Difference Between Throw And Throws Keywords? |
|
Answer» The throw keyword denotes a statement that causes an exception to be INITIATED. It takes the Exception object to be thrown as argument. The exception will be caught by an IMMEDIATELY encompassing try-CATCH construction or propagated further up the calling HIERARCHY. The throws keyword is a modifier of a METHOD that designates that exceptions may come out of the method, either by virtue of the method throwing the exception itself or because it fails to catch such exceptions that a method it calls may throw. The throw keyword denotes a statement that causes an exception to be initiated. It takes the Exception object to be thrown as argument. The exception will be caught by an immediately encompassing try-catch construction or propagated further up the calling hierarchy. The throws keyword is a modifier of a method that designates that exceptions may come out of the method, either by virtue of the method throwing the exception itself or because it fails to catch such exceptions that a method it calls may throw. |
|
| 31. |
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. |
|
| 32. |
What Are Peerless Components? |
|
Answer» The PEERLESS COMPONENTS are CALLED LIGHT WEIGHT components. The peerless components are called light weight components. |
|
| 33. |
What Is A Static Method? |
|
Answer» A static method is a method that BELONGS to the class rather than any OBJECT of the class and doesn't apply to an object or EVEN require that any OBJECTS of the class have been instantiated. A static method is a method that belongs to the class rather than any object of the class and doesn't apply to an object or even require that any objects of the class have been instantiated. |
|
| 34. |
What Is A Protected Method? |
|
Answer» A protected METHOD is a method that can be ACCESSED by any method in its package and INHERITED by any subclass of its CLASS. A protected method is a method that can be accessed by any method in its package and inherited by any subclass of its class. |
|
| 35. |
What Is The Locale Class? |
|
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. |
|
| 36. |
What Is The Properties Class? |
|
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. |
|
| 37. |
How Many Bits Are Used To Represent Unicode, Ascii, Utf-16 And Utf-8 Characters? |
| Answer» | |
| 38. |
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. |
|
| 39. |
Can Each Java Object Keep Track Of All The Threads That Want To Exclusively Access It? |
|
Answer» Yes. Yes. |
|
| 40. |
Can Java Object Be Locked Down For Exclusive Use By A Given Thread? |
|
Answer» Yes. You can lock an object by putting it in a "SYNCHRONIZED" BLOCK. The LOCKED object is INACCESSIBLE to any thread other than the one that explicitly CLAIMED it. Yes. You can lock an object by putting it in a "synchronized" block. The locked object is inaccessible to any thread other than the one that explicitly claimed it. |
|
| 41. |
How Many Methods Are There In The Externalizable Interface? |
|
Answer» There are two methods in the Externalizable INTERFACE. You have to IMPLEMENT these two methods in ORDER to make your class externalizable. These two methods are
There are two methods in the Externalizable interface. You have to implement these two methods in order to make your class externalizable. These two methods are |
|
| 42. |
How Many Methods Are There In The Serializable Interface? |
|
Answer» There is no method in the Serializable INTERFACE. The Serializable interface ACTS as a MARKER, telling the object SERIALIZATION tools that your class is serializable. There is no method in the Serializable interface. The Serializable interface acts as a marker, telling the object serialization tools that your class is serializable. |
|
| 43. |
How To Make A Class Or A Bean Serializable? |
|
Answer» By IMPLEMENTING EITHER the java.io.SERIALIZABLE interface or the java.io.Externalizable interface. As long as one CLASS in a class's inheritance HIERARCHY implements Serializable or Externalizable, that class is serializable. By implementing either the java.io.Serializable interface or the java.io.Externalizable interface. As long as one class in a class's inheritance hierarchy implements Serializable or Externalizable, that class is serializable. |
|
| 44. |
What Is The Serialization? |
|
Answer» The serialization is a KIND of mechanism that makes a CLASS or a bean persistence by having its PROPERTIES or fields and state INFORMATION saved and restored to and from STORAGE. The serialization is a kind of mechanism that makes a class or a bean persistence by having its properties or fields and state information saved and restored to and from storage. |
|
| 45. |
Is Java Code Slower Than Native Code? |
|
Answer» Not really. As a platform-independent environment, the Java platform can be a bit SLOWER than native code. However, SMART COMPILERS, well-tuned interpreters, and just-in-time BYTECODE compilers can bring performance close to that of native code WITHOUT threatening portability. Not really. As a platform-independent environment, the Java platform can be a bit slower than native code. However, smart compilers, well-tuned interpreters, and just-in-time bytecode compilers can bring performance close to that of native code without threatening portability. |
|
| 46. |
What Is Native Code? |
|
Answer» The native code is a code that after you COMPILE it, the compiled code RUNS on a specific hardware PLATFORM. The native code is a code that after you compile it, the compiled code runs on a specific hardware platform. |
|
| 47. |
What Is The Package? |
|
Answer» The PACKAGE is a Java NAMESPACE or part of Java libraries. The Java API is GROUPED into libraries of related classes and interfaces; these libraries are KNOWN as packages. The package is a Java namespace or part of Java libraries. The Java API is grouped into libraries of related classes and interfaces; these libraries are known as packages. |
|
| 48. |
What Is The Java Api? |
|
Answer» The Java API is a large collection of ready-made SOFTWARE components that provide many useful CAPABILITIES, such as graphical user INTERFACE (GUI) widgets. The Java API is a large collection of ready-made software components that provide many useful capabilities, such as graphical user interface (GUI) widgets. |
|
| 49. |
What Is The Java Virtual Machine? |
|
Answer» The JAVA Virtual Machine is SOFTWARE that can be ported ONTO VARIOUS hardware-based platforms. The Java Virtual Machine is software that can be ported onto various hardware-based platforms. |
|
| 50. |
What Is A Platform? |
|
Answer» A PLATFORM is the HARDWARE or software environment in which a program runs. Most PLATFORMS can be described as a combination of the operating system and hardware, like WINDOWS 2000/XP, Linux, Solaris and MACOS. A platform is the hardware or software environment in which a program runs. Most platforms can be described as a combination of the operating system and hardware, like Windows 2000/XP, Linux, Solaris and MacOS. |
|