Font size
Worksheetsinterfaces, final , inheritance
Total questions: 20
Worksheet time: 19mins
Which of the following statement(s) is/are not true?
Hiding internal data from the outside world, and accessing it only through publicly exposed methods is known as data encapsulation.
Common behavior can be defined in a superclass and inherited into a subclass using the extends keyword.
The term "class variable" is another name for non-static field.
A local variable stores temporary state; it is declared inside a method
5
4
3
error
Which of the following is/are TRUE about print() and println() methods?
print() prints in a single line only and multiple lines cannot be printed in any way.
print() prints and then appends a line break.
println()prints and then appends a line break.
println() prints in a single line only and multiple lines cannot be printed.
Which of the following is a valid declaration of an object of class Fun
Fun obj=new Fun;
obj=new Fun();
Fun obj=new Fun();
new Fun obj;
10
0
5
12
0
5
10
5
0
12
0
5
An expression involving byte, int, and literal numbers is promoted to which of these?
int
long
byte
float
25
24
32
33
0 2 4 6 8
1 2 3 4 5
0 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
Which of the following statements are incorrect?
public members of class can be accessed by any code in the program.
private members of class can be inherited by a sub class, and become protected members in sub class.
private members of class can only be accessed by other members of the class.
protected members of a class can be inherited by a sub class, and become private members of the sub class.
0
1
2
compilation error
super keyword in Java is used for ?
to refer to immediate child class of a class.
to refer to current class object.
to refer to immediate parent class of a class.
to refer to static member of parent class.
Which is true ?
"X extends Y" is correct if X and Y are either both classes or both interface.
"X extends Y" is correct if and only if X is a interface and Y is a class.
"X extends Y" is correct for all combinations of X and Y being classes and/or interfaces.
"X extends Y" is correct if and only if X is a class and Y is an interface.
only A and B will be printed.
only B will be printed.
A, B, C will be printed.
only C will be printed.
If a class inheriting an abstract class does not define all of its function then it will be known as?
abstract
A simple class
Static class
None of the mentioned
Which of these is not a correct statement?
Every class containing abstract method must be declared abstract.
Abstract class defines only the structure of the class not its implementation.
Abstract class can be initiated by new operator.
Abstract class can be inherited.
0
2
run time error
compile time error
Which of the statement is false about an abstract class ?
An abstract class is a class that contains one or more abstract methods.
An abstract class cannot have normal method.
An abstract class cannot be instantiated.
An abstract class can be extended.
Which of the following statement is true about an Interface ?
Interface can not be nested inside another interface.
Interface cannot implement a class.
Interface can not extend one or more other interface.
Methods inside Interface can be static, final, native or strictfp.
1,3 and 4
1,2 and 4
2,3 and 4
1,2,3 and 4
1 and 2 only
2,3 and 5
3,4 and 5
2 and 4
