Top 250+ Solved Java Programming MCQ Questions Answer
Q. Which of these methods can be used to obtain the command name for invoking ActionEventobject?
a. getCommand()
b. getActionCommand()
c. getActionEvent()
d. getActionEventCommand()
Q. Which of the following is a valid declaration of an object of class Box?
a. Box obj = new Box();
b. Box obj = new Box;
c. obj = new Box();
d. new Box obj;
Q. Name the keyword that makes a variable belong to a class, rather than being defined for each instance of the class.
a. static
b. final
c. abstract
d. public
Q. Variables declared with in a class are called
a. Identifier
b. local variable
c. instance variable
d. global variable
Q. Variables declared within a method or block are called
a. Static variable
b. local variable
c. instance variable
d. global variable
Q. Defining methods with same name and different no. of parameters are called
a. Method overriding
b. method overloading
c. Dynamic method dispatch
d. none of the above
Q. Which of the following is a method having same name as that of its class?
a. finalize
b. delete
c. class
d. constructor
Q. Which operator is used by Java run time implementations to free the memory of an object when it is no longer needed?
a. delete
b. free
c. new
d. None of the mentione
Q. Which of these access specifiers must be used for main() method?
a. private
b. public
c. protected
d. None of the mentioned
Q. Which of these is used to access member of class before object of that class is created?
a. public
b. private
c. static
d. protected
Q. The method which is automatically invoked during garbage collection.
a. destructor
b. terminate()
c. finalize()
d. destroy()