NEW
Font size
WorksheetsQuiz for Module3
Total questions: 20
Worksheet time: 19mins
Suppose A is an abstract class, B is a concrete subclass of A. Both A and B have a default constructor.
Which of the following options are correct?
1. A a = new A();
2. A a= new B();
3. B b = new A();
4. B b= new B();
1 and 2
2 and 4
3 and 4
1 and 3
Predict the output:
a=10
a=20
Compilation Error at Line 3 : Constructor name should be same as that of class name.
Compilation Error at
Line 7 : Method cannot be both abstract and final,
Line 13 : Cannot override the final method.
Predict the output:
welcome
10
20
Error in Line 2 : Modifier static not allowed here.
Error in Line 7: Modifier static not allowed here.
Compilation Error in both Line 2 and Line 7.
Which one of the below options is correct as per the given piece of code?
SIMRAN
Compilation error : Final variable should be initialized before starting the execution.
Compilation error : Java does not allow final keyword before the constructor.
Compilation error : this keyword cannot be used with final variable.
Predict the output:
Application Successful
Application Successful
Method C
Compilation Error at Line 7 : Cannot extend multiple interfaces.
Compilation Error at Line 10 : Add unimplemented methods.
Identify the lines that can be replaced at /*Insert code here.*/ in the given code to display 100 successfully:
1. Testable.testValue;
2. Test.Testable.testValue;
3. Test.testValue;
4. new Test().testValue;
Option 1 and 2.
Option 2 and 3.
Option 1, 3 & 4.
All the four options.
Predict the output:
NullPointerException
9
5
None of the above
Which one of the following statements will import all the classes from java.util package?
import java.*;
import *.*;
import java.util.*;
import java.util;
Which of the following access specifiers can be used with a class so that it is visible only within the same package?
public
No Access Specifiers
protected
private
Which of the below statements are true about interfaces?
Statement 1: An interface cannot be instantiated.
Statement 2: An interface cannot contain any constructors.
Statement 3: An interface cannot contain instance variables.
Statement 1 ,2 & 3 are true
Statement 1 & 2 are true
Statement 1 & 3 are true
All the statements are false
Predict the output:
int arr[ ] = new int[5];
System.out.println(arr[1]);
1
0
null
Garbage Value
