Java Programming MCQ (Multiple Choice Questions) - SchoolingAxis

Java Programming MCQ (Multiple Choice Questions)

 Que-  what does public String replaceAll(string replace) do?

a. Replace all characters that matches pattern with a replacement string

b. Replace first subsequence that matches pattern with a replacement string

c. Replace all other than first subsequence of that matches pattern with a replacement string

d. Replace every subsequence of the input sequence that matches pattern with a replacement string


Answer- Replace every subsequence of the input sequence that matches pattern with a replacement string


Que-  What does public int start() return?

a. returns start index of the input string

b. returns start index of the current match

c. returns start index of the previous match

d. none of the mentioned


Answer- returns start index of the previous match


Que-  Which of these packages contains all the classes and methods required for even handling in Java?

a. java.applet

b. java.awt

c. java.event

d. java.awt.event


Answer- java.awt.event


Que-  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

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


Answer- An event is an object that describes a state change in a source


Que-  Which of these methods are used to register a keyboard event listener?

a. KeyListener()

b. addKistener()

c. addKeyListener()

d. eventKeyboardListener()


Answer- addKeyListener()


Que-  Which of these methods are used to register a mouse motion listener?

a. addMouse()

b. addMouseListener()

c. addMouseMotionListner()

d. eventMouseMotionListener()


Answer- addMouseMotionListner()


Que-  What is a listener in context to event handling?

a. A listener is a variable that is notified when an event occurs

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


Answer- A listener is a object that is notified when an event occurs


Que-  Event class is defined in which of these libraries?

a. java.io

b. java.lang

c. java.net

d. java.util


Answer- java.util


Que-  Which of these methods can be used to determine the type of event?

a. getID()

b. getSource()

c. getEvent()

d. getEventObject()


Answer- getID()


Que-  Which of these class is super class of all the events?

a. EventObject

b. EventClass

c. ActionEvent

d. ItemEvent


Answer- EventObject


Que-  Which of these events will be notified if scroll bar is manipulated?

a. ActionEvent

b. ComponentEvent

c. AdjustmentEvent

d. WindowEvent


Answer- AdjustmentEvent


Que-  Which of these events will be generated if we close an applet's window?

a. ActionEvent

b. ComponentEvent

c. AdjustmentEvent

d. WindowEvent


Answer- WindowEvent


Que-  Which of these events is generated when a button is pressed?

a. ActionEvent

b. KeyEvent

c. WindowEvent

d. AdjustmentEvent


Answer- ActionEvent


Que-  Which of these methods can be used to obtain the command name for invoking ActionEvent object?

a. getCommand()

b. getActionCommand()

c. getActionEvent()

d. getActionEventCommand()


Answer- getActionCommand()


Que-  Which of these are integer constants defined in ActionEvent class?

a. ALT_MASK

b. CTRL_MASK

c. SHIFT_MASK

d. All of the mentioned


Answer- All of the mentioned


Que-  Which of these methods can be used to know which key is pressed?

a. getKey()

b. getModifier()

c. getActionKey()

d. getActionEvent()


Answer- getModifier()


Que-  Which of these events is generated by scroll bar?

a. ActionEvent

b. KeyEvent

c. WindowEvent

d. AdjustmentEvent


Answer- AdjustmentEvent


Que-  Which of these methods can be used to determine the type of adjustment event?

a. getType()

b. getEventType()

c. getAdjustmentType()

d. getEventObjectType()


Answer- getAdjustmentType()


Que-  Which of these methods can be used to know the degree of adjustment made by the user?

a. getValue()

b. getAdjustmentType()

c. getAdjustmentValue()

d. getAdjustmentAmount()


Answer- getValue()


Que-  Which of these constant value will change when the button at the end of scroll bar was clicked to increase its value?

a. BLOCK_DECREMENT

b. BLOCK_INCREMENT

c. UNIT_DECREMENT

d. UNIT_INCREMENT


Answer- UNIT_INCREMENT


Que-  Which of these events is generated when the size of an event is changed?

a. ComponentEvent

b. ContainerEvent

c. FocusEvent

d. InputEvent


Answer- ComponentEvent


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

a. ComponentEvent

b. ContainerEvent

c. FocusEvent

d. InputEvent


Answer- ContainerEvent


Que-  Which of these methods can be used to obtain the reference to the container that generated a ContainerEvent?

a. getContainer()

b. getContainerCommand()

c. getActionEvent()

d. getContainerEvent()


Answer- getContainerEvent()


Que-  Which of these methods can be used to get reference to a component that was removed from a container?

a. getComponent()

b. getchild()

c. getContainerComponent()

d. getComponentChild()


Answer- getchild()


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

a. COMPONENT_HIDDEN

b. COMPONENT_MOVED

c. COMPONENT_RESIZE

d. All of the mentioned


Answer- All of the mentioned


Que-  Which of these events is generated when computer gains or loses input focus?

a. ComponentEvent

b. ContainerEvent

c. FocusEvent

d. InputEvent


Answer- FocusEvent

Previous Post Next Post