Java MCQs with answers Page - 230

Dear candidates you will find MCQ questions of Java here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
Share your questions by clicking Add Question

A

Admin • 617.67K Points
Coach

Q. Which of this package is used for all the text related modifications?

  • (A) java.text
  • (B) java.awt
  • (C) java.lang.text
  • (D) java.text.mofify

A

Admin • 617.67K 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) ---
  • (D) ---

A

Admin • 617.67K Points
Coach

Q. Which of these can be overloaded?

  • (A) Methods
  • (B) Constructors
  • (C) Both a & b
  • (D) None of the mentioned

A

Admin • 617.67K Points
Coach

Q. Which of the following statements are incorrect?

  • (A) Default constructor is called at the time of declaration of the object if a constructor has not been defined.
  • (B) Constructor can be parameterized.
  • (C) ---
  • (D) ---

A

Admin • 617.67K Points
Coach

Q. You read the following statement in a Java program that compiles and executes. submarine.dive(depth); What can you say for sure?

  • (A) Depth must be an int
  • (B) Dive must be a method.
  • (C) ---
  • (D) ---

A

Admin • 617.67K Points
Coach

Q. If a thread is to be declared as a daemon thread, it must be declared before

  • (A) start method
  • (B) run method
  • (C) stop method
  • (D) none

A

Admin • 617.67K Points
Coach

Q. Consider the following program: import myLibrary.*; public class ShowSomeClass { // code for the class... } What is the name of the java file containing this program?

  • (A) myLibrary.java
  • (B) ShowSomeClass.java
  • (C) ShowSomeClass
  • (D) ShowSomeClass.class 1.

A

Admin • 617.67K Points
Coach

Q. Consider the following code snippet String river = new String(“Columbia”); System.out.println(river.length()); What is printed?

  • (A) 6
  • (B) 7
  • (C) 8
  • (D) Columbia

A

Admin • 617.67K Points
Coach

Q. Consider public class MyClass{ public MyClass(){/*code*/} // more code... } To instantiate MyClass, you would write?

  • (A) MyClass mc = new MyClass();
  • (B) MyClass mc = MyClass();
  • (C) MyClass mc = MyClass;
  • (D) none of these above

A

Admin • 617.67K Points
Coach

Q. In Java Inheritance

  • (A) all fields of a class are private
  • (B) all fields of a class are protected
  • (C) a new class is derived from an existing class
  • (D) The program throws an exception and proceeds to execute the finally block.