[go: up one dir, main page]

0% found this document useful (0 votes)
443 views7 pages

Unit 5 Oops MCQ

The document discusses various topics related to graphics and events in Java programming. It contains questions about the Graphics class, drawing methods, applet life cycle methods, event handling classes and methods, and different types of events like mouse, keyboard, window etc. It tests knowledge of key concepts like listeners, event sources and event types that are important for handling user interactions in Java programs.

Uploaded by

suganya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
443 views7 pages

Unit 5 Oops MCQ

The document discusses various topics related to graphics and events in Java programming. It contains questions about the Graphics class, drawing methods, applet life cycle methods, event handling classes and methods, and different types of events like mouse, keyboard, window etc. It tests knowledge of key concepts like listeners, event sources and event types that are important for handling user interactions in Java programs.

Uploaded by

suganya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

UNIT -V

CS8392-OBJECT ORIENTED PROGRAMMING


III YEAR EEE-V SEM
S. No. Objective Questions (MCQ /True or False / Fill up with Choices )

The Graphics class is the for all graphics contexts.


a) Main class
1 b) Abstract super class
c) Super class
d) Object class
The Graphics class is resides in
a) java.util
b) java.lang
2
c) java.applet
d) java.awt

Syntax to create new Graphics object is create()


a) True
3 b) False

Which method is not part of the Graphics() class


a) clearRect(int x, int y, int width, int height)
4 b) dispose()
c) drawLine(int x1, int y1, int x2, int y2)
d) All of the above
Graphics it is the top level abstract class for all graphics contexts.
5 a) True
b) False

Correct declaration of -drawPolygon method is


a) drawPolygon(Polygon p)
6 b) drawPolygon()
c) drawpolygon(Polygon p)
d) None of the above
The dispose() is used for the disposes of this graphics context and releases any system resources that
it is using.
7 a) True
b) False

Where are the following four methods commonly used?


a) public void add(Component c)
8 b) public void setSize(int width,int height)
c) public void setLayout(LayoutManager m)
d) public void setVisible(boolean)
These two ways are used to create a Frame
By creating the object of Frame class (association)
By extending Frame class (inheritance)
9
a) True
b) False

AWT stands for?


a) Applet Windowing Toolkit
b) Abstract Windowing Toolkit
10
c) Absolute Windowing Toolkit
d) None of the above

Which following method is used to set the graphics current color to the specified color in the
graphics class?
a) public abstract void setFont(Font font)
11 b) public abstract void setColor(Color c)
c) public abstract void drawString(String str, int x, int y)
d) None of the above

Which following class is provides many methods for graphics programming?


a) java.awt
b) java.Graphics
12
c) java.awt.Graphics
d) None of the above

Which of these functions is called to display the output of an applet?


a) display()
13 b) paint()
c) displayApplet()
d) PrintApplet()
Which of these methods can be used to output a string in an applet?
a) display()
14 b) print()
c) drawString()
d) transient()
Which of these methods is a part of Abstract Window Toolkit (AWT) ?
a) display()
15 b) paint()
c) drawString()
d) transient()
Which of these modifiers can be used for a variable so that it can be accessed from any
thread or parts of a program?
16 a) transient
b) volatile
c) global
d) No modifier is needed
Which of these operators can be used to get run time information about an object?
a) getInfo
17 b) Info
c) instanceof
d) getinfoof
What is the Message is displayed in the applet made by the following Java program?

1. import java.awt.*;
2. import java.applet.*;
3. public class myapplet extends Applet
4. {
5. public void paint(Graphics g)
18 6. {
7. g.drawString("A Simple Applet", 20, 20);
8. }
9. }
a) A Simple Applet
b) A Simple Applet 20 20
c) Compilation Error
d) Runtime Error
What is the length of the application box made by the following Java program?

1. import java.awt.*;
2. import java.applet.*;
3. public class myapplet extends Applet
4. {
5. public void paint(Graphics g)
19 6. {
7. g.drawString("A Simple Applet", 20, 20);
8. }
9. }
a) 20
b) 50
c) 100
d) System dependent
What is the length of the application box made the following Java program?

1. import java.awt.*;
2. import java.applet.*;
3. public class myapplet extends Applet
20 4. {
5. Graphic g;
6. g.drawString("A Simple Applet", 20, 20); 7.
}
a) 20
b) Default value
c) Compilation Error
d) d) Runtime Error
Which of these packages contains all the classes and methods required for even handling
in Java?
a) java.applet
21
b) java.awt
c) java.event
d) java.awt.event
What is an event in delegation event model used by Java programming language?
a) An event is an object that describes a state change in a source
22 b) An event is an object that describes a state change in processing
c) An event is an object that describes any change by the user and system
d) An event is a class used for defining object, to create events
Which of these methods are used to register a keyboard event listener?
a) KeyListener()
22 b) addKistener()
c) addKeyListener()
d) eventKeyboardListener()
Which of these methods are used to register a mouse motion listener?
a) addMouse()
23 b) addMouseListener()
c) addMouseMotionListner()
d) eventMouseMotionListener()
What is a listener in context to event handling?
a) A listener is a variable that is notified when an event occurs
24 b) A listener is a object that is notified when an event occurs
c) A listener is a method that is notified when an event occurs
d) None of the mentioned
Event class is defined in which of these libraries?
a) java.io
25 b) java.lang
c) java.net
d) java.util
Which of these methods can be used to determine the type of event?
a) getID()
26 b) getSource()
c) getEvent()
d) getEventObject()
Which of these class is super class of all the events?
a) EventObject
27 b) EventClass
c) ActionEvent
d) ItemEvent
Which of these events will be notified if scroll bar is manipulated?
28 a) ActionEvent
b) ComponentEvent
c) AdjustmentEvent
d)WindowEvent
Which of these events will be generated if we close an applet’s window?
a) ActionEvent
29 b) ComponentEvent
c) AdjustmentEvent
d) WindowEvent
Which of these events is generated when a button is pressed?
30 a) ActionEvent
b) KeyEvent
c) WindowEvent
d) AdjustmentEvent
Which of these methods can be used to obtain the command name for invoking ActionEvent
object?
31 a) getCommand()
b) getActionCommand()
c) getActionEvent()
d) getActionEventCommand()
Which of these are integer constants defined in ActionEvent class?
32 a) ALT_MASK
b) CTRL_MASK
c) SHIFT_MASK
d) All of the mentioned
Which of these methods can be used to know which key is pressed?
33 a) getKey()
b) getModifier()
c) getActionKey() d)
getActionEvent()
Which of these events is generated by scroll bar? a) ActionEvent
34 b) KeyEvent
c) WindowEvent
d) AdjustmentEvent
Which of these methods can be used to determine the type of adjustment event?
35 a) getType()
b) getEventType()
c) getAdjustmentType()
d) getEventObjectType()
Which of these methods can be used to know the degree of adjustment made by the user?
36 a) getValue()
b) getAdjustmentType()
c) getAdjustmentValue()
d) getAdjustmentAmount()
Which of these constant value will change when the button at the end of scroll bar was
37 clicked to increase its value?
a) BLOCK_DECREMENT
b) BLOCK_INCREMENT
c) UNIT_DECREMENT
b) UNIT_INCREMENT
Which of these events is generated when the size of an event is changed?
38 a) ComponentEvent
b) ContainerEvent
c) FocusEvent
d) InputEvent

Which of these events is generated when the component is added or removed?


a) ComponentEvent
39 b) ContainerEvent
c) FocusEvent
d) InputEvent
Which of these methods can be used to obtain the reference to the container that generated
a ContainerEvent?
40 a) getContainer()
b) getContainerCommand()
c) getActionEvent()
d) getContainerEvent()
Which of these methods can be used to get reference to a component that was removed from
a container?
41 a) getComponent()
b) getchild()
c) getContainerComponent()
d) getComponentChild()
Which of these are integer constants of ComponentEvent class?
42 a) COMPONENT_HIDDEN
b) COMPONENT_MOVED
c) COMPONENT_RESIZE
d) All of the mentioned
Which of these events is generated when computer gains or loses input focus?
43 a) ComponentEvent
b) ContainerEvent
c) FocusEvent
d) InputEvent
FocusEvent is subclass of which of these classes?
44 a) ComponentEvent
b) ContainerEvent
c) ItemEvent
d) InputEvent
Which of these methods can be used to know the type of focus change?
45 a) typeFocus()
b) typeEventFocus()
c) isTemporary()
d) isPermanent()
Which of these is superclass of ContainerEvent class?
46 a) WindowEvent
b) ComponentEvent
c) ItemEvent
d) InputEvent
Which of these events is generated when the window is closed?
47 a) TextEvent
b) MouseEvent
c) FocusEvent
d) WindowEvent

Which of these methods can be used to obtain the coordinates of a mouse?


48 a) getPoint()
b) getCoordinates()
c) getMouseXY()
d) getMouseCordinates()
Which of these methods can be used to change location of an event?
49 a) ChangePoint()
b) TranslatePoint()
c) ChangeCordinates()
d) TranslateCordinates()
Which of these methods is used to get x coordinate of the mouse?
50 a) getX()
b) getXCoordinate()
c) getCoordinateX()
d) getPointX()
Which of these is superclass of WindowEvent class?
51 a) WindowEvent
b) ComponentEvent
c) ItemEvent
d)InputEvent
Which of these interfaces handles the event when a component is added to a container?
52 a) ComponentListener
b) ContainerListener
c) FocusListener
d) InputListener
Which of these interfaces define a method actionPerformed()?
53 a) ComponentListener
b) ContainerListener
c) ActionListener
d) InputListener
Which of these methods will respond when you click any button by mouse?
54 a) mouseClicked()
b) mouseEntered()
c) mousePressed()
d) all of the mentioned
55 Which of these methods is defined in MouseMotionAdapter class?
a) mouseDragged()
b) mousePressed()
c) mouseReleased()
mouseClicked()

You might also like