Java Programming Fundamentals and Core Concepts

Test your knowledge of Java programming including loops, class loaders, JVM, garbage collection, polymorphism, collections, interfaces, and exception handling.

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which type of loop in Java executes once, even though the initial condition is false?

  1. While loop
  2. For loop
  3. Do while loop
  4. Iterator
  5. For each loop
Question 2 Multiple Choice (Single Answer)

What is the hierarchy of Class loaders in JAVA?

  1. BootStrap Classloader, Extension Classloader, System Classloader
  2. BootStrap Classloader, System Classloader, Extension Classloader
  3. Extension Classloader, BootStrap Classloader, System Classloader
  4. Extension Classloader, System Classloader, BootStrap Classloader
  5. None of the above
Question 3 Multiple Choice (Single Answer)

Select the correct characteristic of JVM?

  1. JVM is platform independent.
  2. JVM is platform dependent.
  3. JVM is responsible for generating byte code.
  4. JVM generates .class files.
  5. None of the above
Question 4 Multiple Choice (Single Answer)

Which of the following commands is used to suggest to do garbage collection explicitly in Java?

  1. System.garbagecollector()
  2. Runtime.garbagecollector()
  3. System.gc()
  4. Runtime.cg()
  5. None of these
Question 5 Multiple Choice (Single Answer)

The concept of polymorphism can be achieved by_____________ in Java.

  1. constructor
  2. method signature
  3. overriding
  4. delegating
  5. none of the above
Question 6 Multiple Choice (Single Answer)

What is the other name for Primordial class loader in JAVA?

  1. Extension class loader
  2. System class loader
  3. BootStrap class loader
  4. Application class loader
  5. None of the above
Question 7 Multiple Choice (Single Answer)

In which Java package is the collections class is present?

  1. java.util package
  2. java.lang package
  3. java.beans package
  4. java.io package
  5. java.rmi package
Question 8 Multiple Choice (Single Answer)

Which of the following is not true about interfaces in Java?

  1. All methods inside the interfaces are abstract by default.
  2. The access specifiers of all the methods are protected by default.
  3. The variables in interfaces are not final.
  4. Both 1 and 2.
  5. Both 2 and 3.
Question 9 Multiple Choice (Single Answer)

Which of the following is a legacy class defined in the Util package of Java?

  1. Dictionary
  2. Stack
  3. Vector
  4. Properties
  5. All of the above
Question 10 Multiple Choice (Single Answer)

What is/are the difference(s) between comparator and comparable in Java?

  1. Comparator is present in java.Util package and Comparable is present in java.lang Package.
  2. Comparator consists of int Compare(Object o1, Object o2)and Comparable consists of int CompareTo(Object o).
  3. In case of Comparable Sorting, logic must be in the same class whose objects are to be sorted whereas in case of Comparator sorting, logic is in separate class.
  4. All of the above.
  5. None of these
Question 11 Multiple Choice (Single Answer)

Which of the following can be called as marker interfaces in Java?

  1. Collection
  2. Queue
  3. Serializable
  4. Iterable
  5. Runnable
Question 12 Multiple Choice (Single Answer)

What is the difference between Iterator and ListIterator in Java?

  1. ListIterator can iterate in backward direction whereas Iterator cannot.
  2. ListIterator can get index at any point while Iterator cannot.
  3. ListIterator can add a value at any point while Iterator cannot.
  4. All of the above
  5. None of these
Question 13 Multiple Choice (Single Answer)

Which of the following exceptions is thrown by the JVM, when it was unable to find the class that should be loaded at the runtime ?

  1. ClassCastException
  2. IllegalAccessException
  3. ClassNotFoundException
  4. IllegalMonitorStateException
  5. None of the above
Question 14 Multiple Choice (Single Answer)

Which of the following is true in Java?

  1. Static fields are initialized before non static fields.
  2. Non static fields are initialized before static fields.
  3. Both static fields and non static fields are initialized at the same time.
  4. It depends on the JVM.
  5. None of these
Question 15 Multiple Choice (Single Answer)

Which of the above two statements define the equals and hashcode contract in JAVA?

Statement -1 If two objects are equal, then their hash code must be the same.
 Statement -2 If two objects have same hash code, then may or may not be equal.

  1. Only Statement 1
  2. Only Statement 2
  3. Both 1 and 2
  4. Neither Statement 1 nor Statement 2
  5. None of the above