Java Programming Fundamentals

Test your knowledge of Java programming concepts including OOP, collections, exception handling, and multithreading

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which type(s) of linked list is/are used in Java utility package?

  1. Singly linked list
  2. Doubly linked list
  3. Circular linked list
  4. All of the above
  5. None of the above
Question 2 Multiple Choice (Single Answer)

Which of the following statements is wrong?

class superclass

{

}

class subclass extends superclass

{

}

 

  1. superclass superclassref=new superclass();
  2. superclass superclassref=new sublass();
  3. subclass subclassref=new subclass();
  4. subclass subclassref=new superclass();
  5. Any class reference variable cannot reference other class object.
Question 3 Multiple Choice (Single Answer)

What happens in the heap memory when a subclass object is created?

  1. Only for the subclass object, memory will be created.
  2. Only for the superclass object, memory will be created.
  3. Memory for both superclass and subclass will be created and also that memory is referenced by super class reference variable.
  4. Memory for both superclass and subclass will be created and also that memory is referenced by subclass reference variable.
  5. None of the above
Question 4 Multiple Choice (Single Answer)

Which of the following is a deprecated way to read input from standard input?

  1. Using scanner
  2. Using DataInputStream
  3. Using BufferedReader
  4. All of the above
  5. None of the above
Question 5 Multiple Choice (Single Answer)

Which of the following statements is TRUE about Java interfaces?

  1. It is not possible to implement interface in more than one class.
  2. An interface should not have any members except abstract methods.
  3. It is not possible to have reference variables for interfaces.
  4. We cannot create object for interface.
  5. If a class implements two interfaces which have the same method names, then the class should implement all the simlar methods in two interfaces twice.
Question 6 Multiple Choice (Single Answer)

Which of the following is not a checked exception?

  1. IllegalAccessEception
  2. CloneNotSupportedException
  3. ClassNotFoundException
  4. SecurityException
  5. InstantiationException
Question 7 Multiple Choice (Single Answer)

Which of the following is the method in 'Cloneable' interface?

  1. Copy()
  2. Clone()
  3. toString()
  4. finalize()
  5. None of the above
Question 8 Multiple Choice (Single Answer)

Which of the following statements is/are syntactically wrong?

  1. Stack st=new Stack();
  2. Stack<string> st=new Stack<>();</string>
  3. Stack<char> st<>new Stack<char>();</char></char>
  4. Queue<integer> qq=new LinkedList<integer>();</integer></integer>
  5. All of the above
Question 9 Multiple Choice (Single Answer)

In which of the following cases will the finally block not be executed after the try block?

  1. If try block does not have any exceptions.
  2. If try block has a return statement.
  3. If exception is not handled in catch block.
  4. If try block has System.exit(0) statement.
  5. All of the above
Question 10 Multiple Choice (Single Answer)

In which of the following cases can we serialize a function?

  1. If the class does not implement serializable interface.
  2. If it has transient keyword before it.
  3. If it fails to create objects for 'ObjectOutputStream' and 'FileOutputStram'.
  4. If it is overridden.
  5. If it is static.
Question 11 Multiple Choice (Single Answer)

Which of the following is not legacy Class/Interface?

  1. HashMap
  2. Properties
  3. Enumeration
  4. Dictionary
  5. Stack
Question 12 Multiple Choice (Single Answer)

Which of the following data types cannot be used with switch statement?

  1. int
  2. float
  3. char
  4. string
  5. none of the above
Question 13 Multiple Choice (Single Answer)

Which of the following statements is false about Synchronized and ThreadSafety?

  1. In multithreading, synchronized methods or statements used to fix dirty reading.
  2. In Java, all the legacy classes are threadsafe.
  3. Application consumes more time if it uses synchronized blocks.
  4. In Java, we use Synchronized modifier to make a block as thread safe.
  5. None of the above
Question 14 Multiple Choice (Single Answer)

What is the output of the above program?

public class Sss
{
public static
void main(String args[])
 {
 byte a=127; a++;
 System.out.println(a);
 }
}

  1. 127
  2. 0
  3. 128
  4. - 128
  5. Compilation error
Question 15 Multiple Choice (Single Answer)

What is the output of the above program?

public class A

{

             static int a;

           public static void main(String args[])

             {

             System.out.println(a);

             }

}

 

  1. Compilation error
  2. 0
  3. Runtime error
  4. NullpointerException
  5. None of the above