Sample Questions Best site for GRE, LSAT, SAT, GMAT, TOEFL, CCNA, CCSA and interview sample questions  

Technical Sample Questions : C |  C++ |  Oracle |  Java | Unix |  Operating Systems |  Data Structure

Java Sample Questions ›› Java questions

Technical General Java Sample Questions

  1. What does it mean to use a null layout manager, and why would you want to do so?

    Answer: If the layout manager for a container is set to null, then the programmer takes full responsibility for setting the sizes and positions of all of the components in that container.This gives the programmer more control over the layout, but the programmer has to do more work.For simple layouts in a container that does not change size, the setBounds() method of each component can be called when it is added to the container.If the container can change size, then the sizes and positions should be recomputed when a size change occurs.This is done automatically by a layout manager, and this is one good reason to use a layout manager for a container that can change size.

  2. What is a JCheckBox and how is it used?

    Answer: A JCheckBox is a component that has two possible states, "checked" and "unchecked".The user can change the state by clicking on the JCheckBox.If box is a variable of type JCheckBox, then a program can check the box by calling box.setSelected(true) and can uncheck the box by calling box.setSelected(false).The current state can be determined by calling box.isSelected(), which is a boolean-valued function.A JCheckBox generates an event of type ActionEvent when it changes state.A program can listen for these events if it wants to take some action at the time the state changes.Often, however, it's enough for a program simply to look at the state of the JCheckBox when it needs it.

  3. What is a thread ?

    Answer: A thread, like a program, executes a sequence of instructions from beginning to end.Several threads can execute "in parallel" at the same time.In Java, a thread is represented by an object of type Thread.A Thread object has a run() method to execute (usually the run() method of a Runnable object that is provided when the Thread is constructed).The thread begins executing the run() routine when its start() method is called.At the same time, the rest of the program continues to execute in parallel with the thread.

  4. Explain how Timers are used to do animation?

    Answer: Displaying an animation requires showing a sequence of frames.The frames are shown one after the other, with a short delay between each frame and the next.A Timer can generate a sequence of ActionEvents.When a timer is used to do animation, each event triggers the display of another frame.The ActionListener that processes events from the timer just needs to be programmed to display a frame when its actionPerformed() method is called.

  5. Menus can contain sub-menus.What does this mean, and how are sub-menus handled in Java?

    Answer: Menus can be "hierarchical." A menu can contain other menus, which are called sub-menus.A sub-menu is represented as a single item in the menu that contains it.When the user selects this item, the full sub-menu appears, and the user can select an item from the sub-menu.In Java, a sub-menu is no different from any other menu.A menu can be added to a menu bar, or it can be added to another menu.In the latter case, it becomes a sub-menu.

  6. What is the purpose of the JFrame class?

    Answer: An object belonging to the class JFrame is an independent window on the screen.You don't need a Web browser to create a JFrame like you do for an JApplet.A JFrame can be used as a user interface for a stand-alone program.It is also possible for an applet to open a JFrame.

  7. What does the computer do when it executes the following statement? Try to give as complete an answer as possible.

    Color[]pallette=newColor[12];

    Answer: This is a declaration statement, that declares and initializes a variable named pallette of type Color[].The initial value of this variable is a newly created array that has space for 12 items.To be specific about what the computer does: It creates a new 12-element array object on the heap, and it fills each space in that array with null.It allocates a memory space for the variable, pallette.And it stores a pointer to the new array object in that memory space.

  8. What is meant by the basetype of an array?

    Answer: The base type of an array refers to the type of the items that can be stored in that array.For example, the base type of the array in the previous problem is Color.

  9. What does it mean to sort an array?

    Answer: To sort an array means to rearrange the items in the array so that they are in increasing or decreasing order.

  10. What is meant by a dynamic array? What is the advantage of a dynamic array over a regular array?

    Answer: A dynamic array is like an array in that it is a data structure that stores a sequence of items, all of the same type, in numbered locations.It is different from an array in that there is no preset upper limit on the number of items that it can contain.This is an advantage in situations where a reasonable value for the size of the array is not known at the time it is created.

« Previous || Next »

Java Sample Question Number: 1-10| 11-20| 21-30| 31-40| 41-50| 51-60| 61-70| 71-80| 81-90| 91-100| 101-110| 111-120| 121-130| 131-140| 141-150| 151-160| 161-170| 171-180| 181-190| 191-200| 201-210| 211-220| 221-230| 231-240| 241-250| 251-260| 261-270| 271-280| 281-290| 291-300| 301-310| 311-320| 321-330
Sample Test Questions
GRE Sample Questions
CAT Sample Questions
GMAT Sample Questions
TOEFL Sample Questions
ACT Sample Questions
SAT Sample Questions
LSAT Sample Questions
PSAT Sample Questions
MCAT Sample Questions
PMP Sample Questions
GED Sample Questions
ECDL Sample Questions
DMV Sample Questions
CCNA Sample Questions
MCSE Sample Questions
Network+ Sample Questions
A+ Sample Questions
Technical Sample Questions
WASL Sample Questions
CISA Sample Questions

Other Sample Questions
Sample Interview Questions
Sample Teacher Interview Questions
Sample Citizenship Questions
Accuplacer Sample Questions
Science Bowl sample Questions
Driving Test Sample Questions
Sample Survey Questions Sample Essay Questions
Sample Behavioral Interview Questions

Copyright © 2004-2013, Best BSQ. All Rights Reserved.