Java Programming Fundamentals
Test your knowledge of Java programming concepts including OOP, collections, exception handling, and multithreading
Questions
Which type(s) of linked list is/are used in Java utility package?
- Singly linked list
- Doubly linked list
- Circular linked list
- All of the above
- None of the above
Which of the following statements is wrong?
class superclass
{
}
class subclass extends superclass
{
}
- superclass superclassref=new superclass();
- superclass superclassref=new sublass();
- subclass subclassref=new subclass();
- subclass subclassref=new superclass();
- Any class reference variable cannot reference other class object.
What happens in the heap memory when a subclass object is created?
- Only for the subclass object, memory will be created.
- Only for the superclass object, memory will be created.
- Memory for both superclass and subclass will be created and also that memory is referenced by super class reference variable.
- Memory for both superclass and subclass will be created and also that memory is referenced by subclass reference variable.
- None of the above
Which of the following is a deprecated way to read input from standard input?
- Using scanner
- Using DataInputStream
- Using BufferedReader
- All of the above
- None of the above
Which of the following statements is TRUE about Java interfaces?
- It is not possible to implement interface in more than one class.
- An interface should not have any members except abstract methods.
- It is not possible to have reference variables for interfaces.
- We cannot create object for interface.
- 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.
Which of the following is not a checked exception?
- IllegalAccessEception
- CloneNotSupportedException
- ClassNotFoundException
- SecurityException
- InstantiationException
Which of the following is the method in 'Cloneable' interface?
- Copy()
- Clone()
- toString()
- finalize()
- None of the above
Which of the following statements is/are syntactically wrong?
- Stack st=new Stack();
- Stack<string> st=new Stack<>();</string>
- Stack<char> st<>new Stack<char>();</char></char>
- Queue<integer> qq=new LinkedList<integer>();</integer></integer>
- All of the above
In which of the following cases will the finally block not be executed after the try block?
- If try block does not have any exceptions.
- If try block has a return statement.
- If exception is not handled in catch block.
- If try block has System.exit(0) statement.
- All of the above
In which of the following cases can we serialize a function?
- If the class does not implement serializable interface.
- If it has transient keyword before it.
- If it fails to create objects for 'ObjectOutputStream' and 'FileOutputStram'.
- If it is overridden.
- If it is static.
Which of the following is not legacy Class/Interface?
- HashMap
- Properties
- Enumeration
- Dictionary
- Stack
Which of the following data types cannot be used with switch statement?
- int
- float
- char
- string
- none of the above
Which of the following statements is false about Synchronized and ThreadSafety?
- In multithreading, synchronized methods or statements used to fix dirty reading.
- In Java, all the legacy classes are threadsafe.
- Application consumes more time if it uses synchronized blocks.
- In Java, we use Synchronized modifier to make a block as thread safe.
- None of the above
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);
}
}
- 127
- 0
- 128
- - 128
- Compilation error
What is the output of the above program?
public class A
{
static int a;
public static void main(String args[])
{
System.out.println(a);
}
}
- Compilation error
- 0
- Runtime error
- NullpointerException
- None of the above