Gartner Most Frequently Asked Core Java Interview Questions Answers
What Do You Understand By Downcasting?
The process of Downcasting refers to the casting from a general to a more specific type, i.e; casting down the hierarchy.
What Do You Understand By Final Value?
FINAL for a variable: value is constant.
FINAL for a method: cannot be overridden.
FINAL for a class: cannot be derived.
What Are Keyboard Events?
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.
What Is 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.
What Are Controls And Their Different Types In Awt?
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.
What Is The Difference Between Choice And List?
A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices and only one item may be selected from a choice. A List may be displayed in such a way that several list items are visible and it supports the selection of one or more list items.
What Is The Difference Between Scrollbar And Scrollpane?
A Scrollbar is a Component, but not a Container whereas Scrollpane is a Container and handles its own events and perform its own scrolling.
Which Containers Use A Flow Layout As Their Default Layout?
Panel and Applet classes use the FlowLayout as their default layout.
What Are Wrapper Classes?
Wrapper classes are classes that allow primitive types to be accessed as objects.
What Is The Difference Between Set And List?
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.
How Can The Checkbox Class Be Used To Create A Radio Button?
By associating Checkbox objects with a CheckboxGroup.
Which Textcomponent Method Is Used To Set A Textcomponent To The Read-only State?
setEditable().
What Methods Are Used To Get And Set The Text Label Displayed By A Button Object?
getLabel() and setLabel().
What Is The Difference Between Yield() And Sleep()?
When a object invokes yield() it returns to ready state. But when an object invokes sleep() method enters to not ready state.
How To Handle A Web Browser Resize Operation?
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.
Explain The Concept Of Hashtables?
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.
What Do You Understand By Downcasting?
The process of Downcasting refers to the casting from a general to a more specific type, i.e; casting down the hierarchy.
What Do You Understand By Final Value?
FINAL for a variable: value is constant.
FINAL for a method: cannot be overridden.
FINAL for a class: cannot be derived.
What Are Keyboard Events?
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.
What Is 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.
What Are Controls And Their Different Types In Awt?
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.
Gartner Most Frequently Asked Core Java Interview Questions Answers |
What Is The Difference Between Choice And List?
A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices and only one item may be selected from a choice. A List may be displayed in such a way that several list items are visible and it supports the selection of one or more list items.
What Is The Difference Between Scrollbar And Scrollpane?
A Scrollbar is a Component, but not a Container whereas Scrollpane is a Container and handles its own events and perform its own scrolling.
Which Containers Use A Flow Layout As Their Default Layout?
Panel and Applet classes use the FlowLayout as their default layout.
What Are Wrapper Classes?
Wrapper classes are classes that allow primitive types to be accessed as objects.
What Is The Difference Between Set And List?
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.
How Can The Checkbox Class Be Used To Create A Radio Button?
By associating Checkbox objects with a CheckboxGroup.
Which Textcomponent Method Is Used To Set A Textcomponent To The Read-only State?
setEditable().
What Methods Are Used To Get And Set The Text Label Displayed By A Button Object?
getLabel() and setLabel().
What Is The Difference Between Yield() And Sleep()?
When a object invokes yield() it returns to ready state. But when an object invokes sleep() method enters to not ready state.
How To Handle A Web Browser Resize Operation?
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.
Explain The Concept Of Hashtables?
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.
Post a Comment