Java MCQs with answers Page - 24

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 • 832.01K Points
Coach

Q. Which of the following will cause a semantic error, if you are trying to compare x to 5?

  • (A) if (x == 5)
  • (B) if (x = 5)
  • (C) if (x <= 5)
  • (D) if (x >= 5)

A

Admin • 832.01K Points
Coach

Q. How many constructors does the class Exception have?

  • (A) 0
  • (B) 1
  • (C) 2
  • (D) 3

A

Admin • 832.01K Points
Coach

Q. If class Dog has a subclass Retriever, which of the following is true?

  • (A) Because of single inheritance, Dog can have no other subclasses.
  • (B) Because of single inheritance, Retriever can extend no other class except Dog.
  • (C) The relationship between these classes implies that Dog “is-a” Retriever.
  • (D) The relationship between these classes implies that Retriever “has-a” Dog.

A

Admin • 832.01K Points
Coach

Q. If there are three classes: Shape, Circle, and Square, what is the most likely relationship between them?

  • (A) Square is a superclass, and Shape and Circle are subclasses of Square.
  • (B) Shape is a superclass, and Circle and Square are subclasses of Shape.
  • (C) Shape, Circle, and Square are all sibling classes.
  • (D) These three classes cannot be related.

A

Admin • 832.01K Points
Coach

Q. What is byte code in the context of Java?

  • (A) The type of code generated by a Java compiler
  • (B) The type of code generated by a Java Virtual Machine
  • (C) It is another name for a Java source file
  • (D) It is the code written within the instance methods of a class.

A

Admin • 832.01K Points
Coach

Q. What is garbage collection in the context of Java?

  • (A) The operating system periodically deletes all of the java files available on the system.
  • (B) Any package imported in a program and not used is automatically deleted.
  • (C) When all references to an object are gone, the memory used by the object is automatically reclaim
  • (D) None of these

A

Admin • 832.01K Points
Coach

Q. JAR stands for?

  • (A) Java Archive
  • (B) Java Archive Runner
  • (C) Java Application Runner
  • (D) None of the above

A

Admin • 832.01K Points
Coach

Q. What are the pillars of OOPS concept?

  • (A) Abstraction, Inheritance, Encapsulation, Polymorphism
  • (B) Atomicity, Inheritance, Encapsulation, Polymorphism
  • (C) Abstraction, Inheritance, Polymorphism
  • (D) None of the Above

A

Admin • 832.01K Points
Coach

Q. What is the default buffer size used by any buffered class?

  • (A) 128 bytes
  • (B) 256 bytes
  • (C) 512 bytes
  • (D) 1024 bytes

A

Admin • 832.01K Points
Coach

Q. Which class cannot be a subclass in java

  • (A) Abstract class
  • (B) Parent class
  • (C) Final class
  • (D) None of above

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ