Font size
WorksheetsQuiz 3
Total questions: 21
Worksheet time: 15mins
What are the valid statements for abstract classes?
a) it may or may not include abstract methods
b) cannot be instantiated
c) a class can implement multiple abstract classes
d) only permits you to state functionality but not to implement it
To which module does Class Object belong according to the java documentation?
a) javax.base
b) java.lang
c) java.base
c) java.io
What are the valid statements for a Interface in Java?
a) can be extended by a class
b) can be only abstract methods in the Java interface
c) in an interface, you can’t instantiate variables and create an object.
d) the interface cannot contain concrete methods
Being
A1 super class
B1 interface
C1 subclass of A1, and implements B1
Which of the following statements has access to the methods of a1 and a1b1?
a) A1 sc=new C1 ( );
b) C1 sb=new C1 ( );
c) B1 sc=new C1 ( );
InstanceOf syntax
which is correct order?
_1_ instanceOf _2_ ;
a) 1-className
2-objectName
b) 1-objectName
2- className
What are the valid statements for var ?
a) Use var to declare global variables
b) var is a reserved type name
c) var is a keyword
d) it´s only used when the compiler expects a variable type
import java.util.*;
public class GFG { public static void main(String[] args) throws Exception{
Integer a[] = new Integer[] { 10, 20, 30, 40 };
List<int> list = Arrays.asList(a);
System.out.println("The list is: " + list); } }
Does this code compile?
a) yes
b) no
What is the purpose of Predicate<T> Functional Interface?
a) It represents a predicate (Boolean -valued - function) of two argument
b) It represents the subtype
c) It represents a super Type
d) It represents a predicate (Boolean -valued - function) of one argument
What are the valid statements for a Lambda Expression in Java?
a) To provide the implementation of Functional interface
b) Java lambda expression is consisted of two components :
1) Argument-list
2) Body
c)A lambda expression can have zero or any number of arguments
d) Lambda Expressions are the new feature addition and introduced in Java 8
Because of the restriction to define only a single function, the lambda syntax can be used only to implement interfaces that have a single abstract method
witch package provides target types for lambda expressions?
a) java.util.stream
b) java.util.funtions
c) java.util
The closest common ancestor of RuntimeException, Error, IOException and ClassNotFoundException is:
a) Object
b) Exception
c) Throwable
d) Catchable
A method that potentially generates a checked exception must include this keyword in its method signature:
a) throw
b) extend
c) throws
d) extends
Which of the following statements is true about Java's finally block?
a) The finally block is only executed if an exception is thrown in the try block
b) The finally block is only executed if an exception is thrown in the catch block
c) The finally block is only executed if an exception is not thrown in the try or catch block
d) The finally block is executed regardless of whether an exception is thrown in the try or catch block
Which of the following statements is true about exception handling in Java:
a) A try block can have many catch blocks but only one finally block
b) A try block can have many catch blocks and many finally blocks
c) A try block must have one finally block for each catch block
d) A try block must have at least one catch block to have a finally block
Which keyword raises an exception in Java code?
a) try
b) throw
c) break
d) throws
If a statement tries to divide by zero which exception is thrown?
a) NullPointerException
b) NumberFormatException
c) ArithmeticException
d) DivideByZeroException
I will cause a complier error if you did not declare/handle me in your program. I am :
a) Unchecked Exception
b) All Exceptions
c) Checked Exception
Which methods of an object can be accessed via an interface that it implements?
a. All the methods implemented in the object’s class
b. All the methods implemented in the object’s superclass
c. The methods declared in the interface
How can you change the reference type of an object?
a. By calling getReference
b. By casting
c. By declaring a new reference and assigning the object
Which of the following objects are checked exceptions?
a. All objects of type Throwable
b. All objects of type Exception
c. All objects of type Exception that are not of type RuntimeException
d. All objects of type Error
e. All objects of type RuntimeException
Which one of the following statements is true?
a. A RuntimeException must be caught.
b. A RuntimeException must be thrown.
c. A RuntimeException must be caught or thrown.
d. A RuntimeException is thrown automatically.
