You are on page 1of 4

VISION ACADEMY

Institute of Polytechnic and Engineering

Q 1. The Java interpreter is used for the execution of the source code.
(a) True (b) False

Q 2. In order for a source code file, containing the public class Test, to successfully compile, which
of the following must be true?
(a) It must have a package statement (b) It must be named Test.java
(c) It must import java.lang (d) It must declare a public class named Test

Q 3. What output is displayed as the result of executing the following statement?


System.out.println("// Looks like a comment.");
(a) // Looks like a comment
(b) The statement results in a compilation error
(c) Looks like a comment
(d) No output is displayed

Q 4. What is the result of expression 5.45 + "3.2"?


(a) The double value 8.6 (b) The string ""8.6"
(c) The long value 8. (d) The String "5.453.2"

Q 5. Boolean values can be cast into any other primitive type.


(a) True (b) False

Q 6. What is the output of the following program?


public class Question {
public static void main(String args[]) {
String s1 = "abc";
String s2 = "def";
String s3 = s1.concat(s2.toUpperCase( ) );
System.out.println(s1+s2+s3);
}
}
(a) abcdefabcdef (b) abcabcDEFDEF
(c) abcdefabcDEF (d) None of the above

Above Yash Jewelers, In front of Pramod Super Market,


MOB- +917276535329
Ausa Road, Latur
Q.7 String is a wrapper class?
(a) True (b) False

Q.8 Which of the following are true?


(a) The Void class extends the Class class.
(b) The Float class extends the Double class.
(c) The System class extends the Runtime class.
(d) The Integer class extends the Number class.

Q.9 What will happen if you attempt to compile and run the following code?
Integer ten=new Integer(10);
Long nine=new Long (9);
System.out.println(ten + nine);
int i=1;
System.out.println(i + ten);
(a) 19 followed by 20
(b) 19 followed by 11
(c) Error: Can't convert java lang Integer
(d) 10 followed by 1

Q.10 Which of the following are true?


(a) The event-inheritance model has replaced the event-delegation model.
(b) The event-inheritance model is more efficient than the event-delegation model.
(c) The event-delegation model uses event listeners to define the methods of event-handling
classes.
(d) The event-delegation model uses the handleEvent( ) method to support event handling.

Q.11 Which of the following is the highest class in the event-delegation model?
(a) java.util.EventListener
(b) java.util.EventObject
(c) java.awt.AWTEvent
(d) java.awt.event.AWTEvent

Q. 12 When two or more objects are added as listeners for the same event, which listener is first
invoked to handle the event?
(a) The first object that was added as listener.
(b) The last object that was added as listener.
(c) There is no way to determine which listener will be invoked first.
(d) It is impossible to have more than one listener for a given event.

Above Yash Jewelers, In front of Pramod Super Market,


MOB- +917276535329
Ausa Road, Latur
Q. 13 Which of the following components generate action events?
(a) Buttons (b) Labels
(c) Check boxes (d)Windows

Q. 14 Suppose that you want to have an object eh handle the TextEvent of a TextArea object t. How
should you add eh as the event handler for it?
(a) t.addTextListener(eh); (b) eh.addTextListener(t);
(c) addTextListener(eh.t); (d) addTextListener(t,eh);

Q. 15 Which of the following are true?


i) A component may handle its own events by adding itself as an event listener.
ii) A component may handle its own events by overriding its event-dispatching method.
iii) A component may not handle oits own events.
iv) A component may handle its own events only if it implements the handleEvent( ) method.

a) i b) ii c) i and ii d) iii and iv

Q. 16 How would you set the color of a graphics context called g to cyan?
(a) g.setColor(Color.cyan);
(b) g.setCurrentColor(cyan);
(c) g.setColor("Color.cyan");
(d) g.setColor(new Color(cyan));

Q. 17 What does the following code draw?


g.setColor(Color.black);
g.drawLine(10, 10, 10, 50);
g.setColor(Color.RED);
g.drawRect(100, 100, 150, 150);

(a) A red vertical line that is 40 pixels long and a red square with sides of 150 pixels
(b) A black vertical line that is 40 pixels long and a red square with sides of 150 pixels
(c) A black vertical line that is 50 pixels long and a red square with sides of 150 pixels
(d) A red vertical line that is 50 pixels long and a red square with sides of 150 pixels

Q. 18 What code would you use to construct a 24-point bold serif font?
(a) new Font(Font.SERIF, 24,Font.BOLD);
(b) new Font(Font.SERIF, "BOLD", 24);
(c) new Font("BOLD ", 24,Font.SERIF);
(d) new Font(Font.SERIF, "BOLD", 24);

Above Yash Jewelers, In front of Pramod Super Market,


MOB- +917276535329
Ausa Road, Latur
Q. 19 Which of the following methods are invoked by the AWT to support paint and repaint
operations?
(a) paint() (b)repaint()
(c) draw() (d)redraw()

Q. 20 Which Component method is used to access a component's immediate Container?


(a) getVisible() (b) getImmediate
(c) getParent() (d) getContainer.

Q. 21 Which of the following creates a List with 5 visible items and multiple selection enabled?
(a) new List(5, true)
(b) new List(true, 5)
(c) new List(5, false)
(d) new List(false,5)

Q. 22 Suppose a Panel is added to a Frame and a Button is added to the Panel. If the Frame’s font is
set to 12-point TimesRoman, the Panel’s font is set to 10-point TimesRoman, and the Button’s font
is not set, what font will be used to dispaly the Button’s label?
(a) 12-point TimesRoman
(b) 11-point TimesRoman
(c) 10-point TimesRoman
(d) 9-point TimesRoman

Q. 23 A Frame’s background color is set to Color.Yellow, and a Button’s background color is to


Color.Blue. Suppose the Button is added to a Panel, which is added to the Frame. What background
color will be used with the Panel?
(a) Color.Yellow (b) Color.Blue
(c) Color.Green (d) Color.White

Q.24 Which method will cause a Frame to be displayed?


i) show( )
ii) setVisible( )
iii) display( )

a) i b) ii c) i and ii d) iii

Q. 25 Which method returns the preferred size of a component?


(a) getPreferredSize( ) (b) getPreferred( )
(c) getRequiredSize( ) (d) getLayout( )

Above Yash Jewelers, In front of Pramod Super Market,


MOB- +917276535329
Ausa Road, Latur

You might also like