wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz 3

Total questions: 21

Worksheet time: 15mins

Name
Class
Date
1.

What are the valid statements for abstract classes?

a)

a) it may or may not include abstract methods

b)

b) cannot be instantiated

c)

c) a class can implement multiple abstract classes

d)

d) only permits you to state functionality but not to implement it

2.

To which module does Class Object belong according to the java documentation?

a)

a) javax.base

b)

b) java.lang

c)

c) java.base

d)

c) java.io

3.

What are the valid statements for a Interface in Java?

a)

a) can be extended by a class

b)

b) can be only abstract methods in the Java interface

c)

c) in an interface, you can’t instantiate variables and create an object.

d)

d) the interface cannot contain concrete methods

4.

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)

a) A1 sc=new C1 ( );

b)

b) C1 sb=new C1 ( );

c)

c) B1 sc=new C1 ( );

5.

InstanceOf syntax

which is correct order?

_1_ instanceOf _2_ ;

a)

a) 1-className

2-objectName

b)

b) 1-objectName

2- className

6.

What are the valid statements for var ?

a)

a) Use var to declare global variables

b)

b) var is a reserved type name

c)

c) var is a keyword

d)

d) it´s only used when the compiler expects a variable type

7.

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)

a) yes

b)

b) no

8.

What is the purpose of Predicate<T> Functional Interface?

a)

a) It represents a predicate (Boolean -valued - function) of two argument

b)

b) It represents the subtype

c)

c) It represents a super Type

d)

d) It represents a predicate (Boolean -valued - function) of one argument

9.

What are the valid statements for a Lambda Expression in Java?

a)

a) To provide the implementation of Functional interface

b)

b) Java lambda expression is consisted of two components :

1) Argument-list

2) Body

c)

c)A lambda expression can have zero or any number of arguments

d)

d) Lambda Expressions are the new feature addition and introduced in Java 8

e)

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

10.

witch package provides target types for lambda expressions?

a)

a) java.util.stream

b)

b) java.util.funtions

c)

c) java.util

11.

The closest common ancestor of RuntimeException, Error, IOException and ClassNotFoundException is:

a)

a) Object

b)

b) Exception

c)

c) Throwable

d)

d) Catchable

12.

A method that potentially generates a checked exception must include this keyword in its method signature:

a)

a) throw

b)

b) extend

c)

c) throws

d)

d) extends

13.

Which of the following statements is true about Java's finally block?

a)

a) The finally block is only executed if an exception is thrown in the try block

b)

b) The finally block is only executed if an exception is thrown in the catch block

c)

c) The finally block is only executed if an exception is not thrown in the try or catch block

d)

d) The finally block is executed regardless of whether an exception is thrown in the try or catch block

14.

Which of the following statements is true about exception handling in Java:

a)

a) A try block can have many catch blocks but only one finally block

b)

b) A try block can have many catch blocks and many finally blocks

c)

c) A try block must have one finally block for each catch block

d)

d) A try block must have at least one catch block to have a finally block

15.

Which keyword raises an exception in Java code?

a)

a) try

b)

b) throw

c)

c) break

d)

d) throws

16.

If a statement tries to divide by zero which exception is thrown?

a)

a) NullPointerException

b)

b) NumberFormatException

c)

c) ArithmeticException

d)

d) DivideByZeroException

17.

I will cause a complier error if you did not declare/handle me in your program. I am :

a)

a) Unchecked Exception

b)

b) All Exceptions

c)

c) Checked Exception

18.

Which methods of an object can be accessed via an interface that it implements?

a)

a. All the methods implemented in the object’s class

b)

b. All the methods implemented in the object’s superclass

c)

c. The methods declared in the interface

19.

How can you change the reference type of an object?

a)

a. By calling getReference

b)

b. By casting

c)

c. By declaring a new reference and assigning the object

20.

Which of the following objects are checked exceptions?

a)

a. All objects of type Throwable

b)

b. All objects of type Exception

c)

c. All objects of type Exception that are not of type RuntimeException

d)

d. All objects of type Error

e)

e. All objects of type RuntimeException

21.

Which one of the following statements is true?

a)

a. A RuntimeException must be caught.

b)

b. A RuntimeException must be thrown.

c)

c. A RuntimeException must be caught or thrown.

d)

d. A RuntimeException is thrown automatically.