Java MCQs with answers Page - 12

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. Which of these is a mechanism for naming and visibility control of a class and its content?

  • (A) Object
  • (B) Packages
  • (C) Interfaces
  • (D) None of the Mentioned

A

Admin • 831.35K Points
Coach

Q. Which of this access specifies can be used for a class so that its objects can be created by a different class in another package?

  • (A) Public
  • (B) Protected
  • (C) No Modifier
  • (D) All of the mentioned

A

Admin • 831.35K Points
Coach

Q. Which of the following is correct way of importing an entire package ‘pkg’?

  • (A) import pkg.
  • (B) Import pkg.
  • (C) import pkg.*
  • (D) Import pkg.*

A

Admin • 831.35K Points
Coach

Q. Which of the following is incorrect statement about packages?

  • (A) Package defines a namespace in which classes are stored.
  • (B) A package can contain other package within it.
  • (C) Java uses file system directories to store packages.
  • (D) A package can be renamed without renaming the directory in which the classes are stored.

A

Admin • 831.35K Points
Coach

Q. Which of these method of class String is used to extract a single character from a String object?

  • (A) CHARAT()
  • (B) chatat()
  • (C) charAt()
  • (D) ChatAt()

A

Admin • 831.35K Points
Coach

Q. Which of these method of class String is used to obtain length of String object?

  • (A) get()
  • (B) Sizeof()
  • (C) lengthof()
  • (D) length()

A

Admin • 831.35K Points
Coach

Q. Which of these keywords is not a part of exception handling?

  • (A) try
  • (B) finally
  • (C) thrown
  • (D) catch

A

Admin • 831.35K Points
Coach

Q. The code within the ----------- block will always be executed whether or not an exception is thrown.

  • (A) try..catch
  • (B) finally
  • (C) throw
  • (D) throws

A

Admin • 831.35K Points
Coach

Q. Which of these keywords is used to manually throw an exception?

  • (A) try
  • (B) finally
  • (C) throw
  • (D) catch

A

Admin • 831.35K Points
Coach

Q. Which of these keywords must be used to monitor for exceptions?

  • (A) try..catch
  • (B) finally
  • (C) throw
  • (D) throws