Java MCQs with answers Page - 8

Here, you will find a collection of MCQ questions on Java. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 831.35K Points
Coach

Q. The keyword used to create a constant variable

  • (A) const
  • (B) static
  • (C) final
  • (D) none of these

A

Admin • 831.35K Points
Coach

Q. What is stored in the object obj in following lines of code? box obj;

  • (A) Memory address of allocated memory of object.
  • (B) NULL
  • (C) Any arbitrary pointer
  • (D) Garbage

A

Admin • 831.35K Points
Coach

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;

A

Admin • 831.35K Points
Coach

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

A

Admin • 831.35K Points
Coach

Q. Variables declared with in a class are called

  • (A) Identifier
  • (B) local variable
  • (C) instance variable
  • (D) global variable

A

Admin • 831.35K Points
Coach

Q. Variables declared within a method or block are called

  • (A) Static variable
  • (B) local variable
  • (C) instance variable
  • (D) global variable

A

Admin • 831.35K Points
Coach

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

A

Admin • 831.35K Points
Coach

Q. _________ is used to initialize objects.

  • (A) Methods
  • (B) arguments
  • (C) constructors
  • (D) new keyword

A

Admin • 831.35K Points
Coach

Q. What is the return type of Constructors?

  • (A) int
  • (B) float
  • (C) void
  • (D) None of the mentioned

A

Admin • 831.35K Points
Coach

Q. Which of the following is a method having same name as that of its class?

  • (A) finalize
  • (B) delete
  • (C) class
  • (D) constructor