Test Your Java 7 and Test Your Java 8 are advanced questions. Answers are given for each question at the end of each test. Answering these questions increases your knowledge in Java and helps you a lot when you appear for interviews. Solving these basic questions is your first step for Certification Exams preparation.
Test Your Java 5
- g.drawRoundRect(50, 50, 100, 100, 200, 200);
The above statement produces a
a) rectangle b) rounded rectangle c) square d) rounded square e) circle f) none - Frame and panels are called containers having a title bar.
a) True b) False - MenuComponent is the subclass of Component.
a) True b) False - Which of the following uses a drop-down (popup window) list.
a) Choice b) List c) a and b d) TextArea e) Canvas f) none ) - If a component is to be redrawn, ___________________ method is to be called.
a) paint() b) repaint() c) update() d) remove() e) none - Scrollbar generates _________________ event.
a) Action b) Item c) Adjustment d) Mouse and MouseMotion e) none - What is the default alignment for Label ?
a) left b) center c) right d) none - Name two components that do not generate any events?
Your answer here ______________ and ______________ . - Radio buttons are a group of buttons (created by instantiating Button class) with a distinct name.
a) True b) False - .
public void init() { CheckboxGroup cbg = new CheckboxGroup(); Checkbox cb = new Checkbox("Open", cbg, true); add(cbg); }
The above fraction of code displays the checkbox cb with the label Open.
a) True b) False - .
Choice c1 = new Choice(); c1.additem("White"); c1.add("Black"); c1.add("Green"); c1.insert("Red", 10); add(c1, "Center"); System.out.println(c1.getItemCount());
The output of the println statement is
a) 4 b) 3 c) 5 d) 10 e) none - We can not create a dialog box to an applet.
State a) True b) false - List method getRows() returns the total number of items in the list.
a) True b) False - The superclass of java.awt.AWTEvent is java.util.EvenObject.
a) True b) False - ActionListener interface contains _____________ number of methods.
a) 1 b) 2 c) 3 d) more than 3 e) none - Button, List, MenuItem and TextField : all are handled by ActionListener.
a) True b) False - The interface AdjustmentListener contains the method
a) public void adjustmentValueChanged(AdjustmentEvent e);
b) public void adjustmentStateChanged(AdjustmentEvent e);
c) public void adjustmentChanged(AdjustmentEvent e);
d) public void adjustmentValuePerformed(AdjustmentEvent e); e) none - Button btn = new Button(“Open”);
btn.addItemListener(this);
In the above code, Button btn has registered with ItemListener instead of ActionListener.
a) The code does not compile b) compiles but throws exception
c) compiles, runs but events are not caught d) none - java.awt.AWTEvent differentiates the events by their
a) getEvent() b) EVENT_MASK c) id d) processEvent() e) none - The default implementation of each method in an adapter class has an empty body.
a) True b) False - What is the default spacing (in pixels) in between the components in a FlowLayout Manager?
a) 0 b) 5 c) 10 d) depends only on the value we give e) none - A panel is placed inside a Frame container. What layout is adopted by the panel implicitly?
a) FlowLayout b) BorderLayout c) GridLayout d) a or b e) none - Which of the following layout manager honors the preferred size of the component.
a) FlowLayout b) BorderLayout c) GridLayout d) a or b e) none - Component List can listen to both ActionListener and ItemListener.
a) True b) False - Graphics g = new Graphics();
public void paint(g) { g.drawString(“Hello”, 25, 50); }
The above program displays Hello at co-ordinates 25, 50.
a) True b) False
ANSWERS
1. e | 2. b | 3. b | 4. a | 5. b |
6. c | 7. b | 8. Label, Panel | 9. b | 10. b |
11. a | 12. a | 13. b | 14. a | 15. a |
16. a | 17. a | 18. a | 19. c | 20. a |
21. b | 22. a | 23. a | 24. a | 25. b |
Correct Answers |
---|
1 to 5 : Poor |
6 t0 10: Below average |
11 t0 15: Average |
16 to 20: Good |
Above 20: Extraordinary |
Pass your comments and suggestions for the improvement of this "Test Your Java 5".