Java Programming MCQ (Multiple Choice Questions) - SchoolingAxis

Java Programming MCQ (Multiple Choice Questions)

 Que-  FocusEvent is subclass of which of these classes?

a. ComponentEvent

b. ContainerEvent

c. ItemEvent

d. InputEvent


Answer- ComponentEvent


Que-  Which of these methods can be used to know the type of focus change?

a. typeFocus()

b. typeEventFocus()

c. isTemporary()

d. isPermanent()


Answer- isTemporary()


Que-  Which of these is superclass of ContainerEvent class?

a. WindowEvent

b. ComponentEvent

c. ItemEvent

d. InputEvent


Answer- ComponentEvent


Que-  Which of these events is generated when the window is closed?

a. TextEvent

b. MouseEvent

c. FocusEvent

d. WindowEvent


Answer- WindowEvent


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

a. getPoint()

b. getCoordinates()

c. getMouseXY()

d. getMouseCordinates()


Answer- getPoint()


Que-  Which of these methods can be used to change location of an event?

a. ChangePoint()

b. TranslatePoint()

c. ChangeCordinates()

d. TranslateCordinates()


Answer- TranslatePoint()


Que-  Which of these are integer constants of TextEvent class?

a. TEXT_CHANGED

b. TEXT_FORMAT_CHANGED

c. TEXT_VALUE_CHANGED

d. TEXT_sIZE_CHANGED


Answer- TEXT_VALUE_CHANGED


Que-  Which of these methods is used to obtain the object that generated a WindowEvent?

a. getMethod()

b. getWindow()

c. getWindowEvent()

d. getWindowObject()


Answer- getWindow()


Que-  MouseEvent is subclass of which of these classes?

a. ComponentEvent

b. ContainerEvent

c. ItemEvent

d. InputEvent


Answer- InputEvent


Que-  Which of these methods is used to get x coordinate of the mouse?

a. getX()

b. getXCoordinate()

c. getCoordinateX()

d. getPointX()


Answer- getX()


Que-  Which of these are constants defined in WindowEvent class?

a. WINDOW_ACTIVATED

b. WINDOW_CLOSED

c. WINDOW_DEICONIFIED

d. All of the mentioned


Answer- All of the mentioned


Que-  Which of these is superclass of WindowEvent class?

a. WindowEvent

b. ComponentEvent

c. ItemEvent

d. InputEvent


Answer- ComponentEvent


Que-  Which of these packages contains all the event handling interfaces?

a. java.lang

b. java.awt

c. java.awt.event

d. java.event


Answer- java.awt.event


Que-  Which of these interfaces handles the event when a component is added to a container?

a. ComponentListener

b. ContainerListener

c. FocusListener

d. InputListener


Answer- ContainerListener


Que-  Which of these interfaces define a method actionPerformed()?

a. ComponentListener

b. ContainerListener

c. ActionListener

d. InputListener


Answer- ActionListener


Que-  Which of these interfaces define four methods?

a. ComponentListener

b. ContainerListener

c. ActionListener

d. InputListener


Answer- ComponentListener


Que-  Which of these interfaces define a method itemStateChanged()?

a. ComponentListener

b. ContainerListener

c. ActionListener

d. ItemListener


Answer- ItemListener


Que-  Which of these methods will respond when you click any button by mouse?

a. mouseClicked()

b. mouseEntered()

c. mousePressed()

d. all of the mentioned


Answer- all of the mentioned


Que-  Which of these methods will be invoked if a character is entered?

a. keyPressed()

b. keyReleased()

c. keyTyped()

d. keyEntered()


Answer- keyTyped()


Que-  Which of these methods is defined in MouseMotionAdapter class?

a. mouseDragged()

b. mousePressed()

c. mouseReleased()

d. mouseClicked()


Answer- mouseDragged()


Que-  Which of these is a superclass of all Adapter classes?

a. Applet

b. ComponentEvent

c. Event

d. InputEvent


Answer- Applet


Que-  Which class is used to generate random number?

a. java.lang.Object

b. java.util.randomNumber

c. java.util.Random

d. java.util.Object


Answer- java.util.Random


Que-  Which method is used to generate boolean random values in java?

a. nextBoolean()

b. randomBoolean()

c. previousBoolean()

d. generateBoolean()


Answer- nextBoolean()


Que-  What is the return type of Math.random() method?

a. Integer

b. Double

c. String

d. Boolean


Answer- Double


Que-  Random is a final class?

a.TRUE

b.FALSE

c.Nothing Can be Said

d.None of the mentioned


Answer-FALSE


Que-  What is the range of numbers returned by Math.random() method?

a. -1.0 to 1.0

b. -1 to 1

c. 0 to 100

d. 0.0 to 1.0


Answer- 0.0 to 1.0


Que-  How many bits are used for generating random numbers?

a.32

b.64

c.48

d.8


Answer-48


Que-  What will be the output of the following Java code snippet?  int a = random.nextInt(15) + 1;

a. Random number between 1 to 15, including 1 and 15

b. Random number between 1 to 15, excluding 15

c. Random number between 1 to 15, excluding 1

d. Random number between 1 to 15, excluding 1 and 15


Answer- Random number between 1 to 15, including 1 and 15

Previous Post Next Post