Font size
WorksheetsJava Quiz (OOP Concepts & Exception Handling)
Total questions: 100
Worksheet time: 2hrs 40mins
What is the output of this program?
0
1
2
Compilation Error
What is the output of this program?
2 2
3 3
2 3
3 2
What is the output of this program?
1 2
2 1
Runtime Error
Compilation Error
what is the output?
Base
Derived
compile time error
run-time error
Output of following Java program?
Base
Derived
Derived
Base
Base
Derived
Base
Derived
Base
Compiler Error
Which of the following is true about inheritance in Java?
1, 2 and 4
Only 1 and 2
1, 2 and 3
2, 3 and 4
output of the program
Base::show() called
Compiler Error
Derived::show() called
None
output of the program
Base::show() called
Derived::show() called
Compiler Error
Runtime Error
Output of following Java Program?
Derived::show() called
compile time error
Base::show() called
runtime error
Predict the output of following Java program?
0
garbage value
compile time error
runtime error
Predict the output of following Java program
garbage value
0
compile time error
runtime error
output of the program
Compile error
values of obj1:
a = 11 b = 21
values of obj2:
a = 11 b = 21
values of obj1:
a = 11 b = 21
values of obj2:
a = 10 b = 20
values of obj1:
a = 11 b = 20
values of obj2:
a = 10 b = 21
runtime error
Predict the output of the following program.
Compilation error
Inside First
Inside First
Inside First
Inside Second
Runtime error
What is the output of the following JAVA program ?
dogood : dogoodgood
dogood : gooddogood
dogood : dodogood
dogood : dogood
Predict the output?
20
0
Compiler Error
none
Which of the following is/are true about constructors in Java?
1
1,2
1, 2, 4
1,2,3 & 4
output of the program
inside static block
a = 4
inside constructor
a = 11
Compiler Error
Run Time Error
inside static block
a = 4
inside constructor
a = 5
inside static block
a = 10
inside constructor
a = 11
What is the process of defining a method in a subclass having same name & type signature as a method in its superclass?
Method overloading
Method overriding
Method hiding
None of the mentioned
What is the output of this program?
2
3
7
compile time error
what is the output
9.0 9.0
9 9
compile time error
none
I am a Person
I am a Student
I am a Person I am a Student
I am a Student I am a Person
Determine the output?
one
one two
one two 20
20
one 20
A Package is the collection of
classes
interfaces
classes and interfaces
editing tools
editing tools and interfaces
which of these lines will give compile time error?
1
2
3
4
None of these
The class at the top of the exception hierarchy is
ArithmeticException
Throwable
Object
Exception
in which package Exception class is available?
java.util
java.file
java.io
java.lang
java.net
Exception generated in try block will caught in...... block
catch
throw
throws
finally
which keyword is used to explicitly throw an exception?
try
throwing
catch
throw
throws
which exception will through by decided by zero?
NumberFormatException
ArithmeticException
NullPointerException
None of these
What happen in case of multiple catch blocks
Either super or subclass can be caught first.
The superclass exception must be caught first.
The superclass exception cannot caught first.
None of these
What will be the output?
inCatchBlock
inCatchBlock inFinallyBlock
inFinallyBlock
The program will return without printing anything
Given the following piece of code
1 and 4
2 and 3
2 and 4
3 and 4
1 and 2
what is the output?
There is a NullPointerException.
There is a NullPointerException. Everything went fine.
There is a NullPointerException. There is an Exception.
This code will not compile, because in Java there are no pointers.
what is the output?
One
Two
One Two
Compilation Error
What is the output?
"doCdoBdoA" is printed
"doAdoBdoC" is printed
"doBdoAerror" is printed
"error" is printed
nothing is printed
what will be the result if NullPointerException occurs at line 2.
1
3
2 3
1 3
1 2 3
What is the output?
"one" is printed.
"null pointer exception" is printed.
"exception" is printed.
Compilation fails saying NullPointerException has already been caught.
None of these
Is this program create a new file with a.txt
true
false
None of these
Compilation Error
what is the output?
Value-A
Compilation fails-Exception NullPointerException is not compatible with throws clause in A.printName()
Name-B
Compilation succeed but no output
None of these
What is the output of this program?
Prints out: Exception
Prints out: Exception Finally
Compile with error
Prints out: Finally
None of these
What is the output?
3
3.5
Compilation Error
None of these
what exception could be handled by catch block
IllegalStateException
ClassCastException
NumberFormatException
ArrayIndexOutOfBoundsException
None of these
What is the output?
Got the Exception 10
Got the Exception 0
Compiler Error
none of the above
What is the output?
Got the Test Exception
Inside finally block
Got the Test Exception
Inside finally block
Compiler Error
What is the output?
Compile error
Divide by zero error
a = 0
Divide by zero error
inside the finally block
a = 0
inside the finally block
What is the output?
error occurred
End of the program
Not Eligible for voting
End of the program
Eligible for voting
End of the program
none
Determine the output?
one
one two
one two 20
20
one 20
Read the Program
1 and 2
2 and 4
3 and 4
1 and 3
Read the following code
The keywords public and abstract cannot be used together.
The method numberOfStudent() in class School must have a body.
You must add a return statement in method numberOfStudent().
Class School must be defined abstract.
Which of the following is the legal abstract class?
class A { abstract void unfinished() { } }
class A { abstract void unfinished(); }
abstract class A { abstract void unfinished(); }
public class abstract A { abstract void unfinished(); }
which of the following the abstract method in the abstract class?
public abstract method();
public abstract void method();
public void abstract Method();
public abstract void method() {}
which of the following statements are true about abstract class?
An abstract class can be extended.
A subclass of a non-abstract superclass can be abstract.
A subclass can override a concrete method in a superclass to declare it abstract.
An abstract class can be used as a data type.
All of the above
read the statement
1 and 2
2 and 4
3 and 4
1 and 3
2 and 3
which of the following is correct about interface?
interface A { void print() { } }
abstract interface A { print(); }
abstract interface A { abstract void print(); { }}
interface A { void print(); }
what is the output?
Nothing.
b is an instance of A.
b is an instance of C.
b is an instance of A followed by b is an instance of C.
given the following piece of code
This code will not compile, because method doYourJob() in interface Guard must be defined abstract.
This code will not compile, because class Dog must implement method doYourJob() from interface Guard.
This code will not compile, because in the declaration of class Dog we must use the keyword extends instead of implements.
This code will compile without any errors.
What will be the output?
will print Class One method
will print Class Two method
compiles fine but print nothing
Compilation Error
None of these
which of these lines will give compile time error?
1
2
3
4
None of these
What will happen after compiling this program?
Successful run and print 37
Compilation error due to line 1
Compilation error due to line 2
Runtime error
None of these
What is the output?
Compilation fails due to an error on line 3
A
Compilation fails due to an error on line 8
null
None of these
what will be the output?
test-name
Compilation fails due to an error on lines 2
Compilation fails due to an error on lines 1
Compilation succeed but Runtime Exception
None of these
What will be the output?
Compile with error
10
12
Runtime Exception
None of these
What is the output?
The code will lead to a compilation error as declaration of the display method has been provided in two interface.
The code will lead to a compilation error due to public modifier while declaring the display method.
The code will compile and execute successfully showing the output Welcome to Examveda.
The code will lead to a compilation error as the display method is not declared as abstract.
None of these
The class at the top of the exception hierarchy is
ArithmeticException
Throwable
Class
Exception
in which package Exception class is available?
java.util
java.file
java.io
java.lang
java.net
Exception generated in try block will caught in...... block
catch
throw
throws
finally
which keyword is used to explicitly throw an exception?
try
throwing
catch
throw
throws
which exception will through by decided by zero?
NumberFormatException
ArithmeticException
NullPointerException
None of these
What happen in case of multiple catch blocks
Either super or subclass can be caught first.
The superclass exception must be caught first.
The superclass exception cannot caught first.
None of these
What will be the output?
inCatchBlock
inCatchBlock inFinallyBlock
inFinallyBlock
The program will return without printing anything
Given the following piece of code
1 and 4
2 and 3
2 and 4
3 and 4
1 and 2
what is the output?
There is a NullPointerException.
There is a NullPointerException. Everything went fine.
There is a NullPointerException. There is an Exception.
This code will not compile, because in Java there are no pointers.
what is the output?
One
Two
One Two
Compilation Error
What is the output?
"doCdoBdoA" is printed
"doAdoBdoC" is printed
"doBdoAerror" is printed
"error" is printed
nothing is printed
Which of this keyword must be used to inherit a class?
super
this
extent
extends
A class member declared protected becomes a member of subclass of which type?
public member
private member
protected member
static member
Which of these is correct way of inheriting class A by class B?
class B + class A {}
class B inherits class A {}
class B extends A {}
class B extends class A {}
What is the output of this program?
0
1
2
Compilation Error
What is the output of this program?
2 2
3 3
2 3
3 2
What is the output of this program?
1 2
2 1
Runtime Error
Compilation Error
What is not type of inheritance?
Single inheritance
Double inheritance
Hierarchical inheritance
Multiple inheritance
what is the output?
Base
Derived
compile time error
run-time error
Output of following Java program?
Base
Derived
Derived
Base
Base
Derived
Base
Derived
Base
Compiler Error
output of the program
Base::show() called
Compiler Error
Derived::show() called
None
output of the program
Base::show() called
Derived::show() called
Compiler Error
Runtime Error
Output of following Java Program?
Derived::show() called
compile time error
Base::show() called
runtime error
Predict the output of following Java program?
0
garbage value
compile time error
runtime error
Predict the output of following Java program
garbage value
0
compile time error
runtime error
output of the program
Compile error
values of obj1:
a = 11 b = 21
values of obj2:
a = 11 b = 21
values of obj1:
a = 11 b = 21
values of obj2:
a = 10 b = 20
values of obj1:
a = 11 b = 20
values of obj2:
a = 10 b = 21
runtime error
Predict the output of the following program.
Compilation error
Inside First
Inside First
Inside First
Inside Second
Runtime error
What is the output of the following JAVA program ?
dogood : dogoodgood
dogood : gooddogood
dogood : dodogood
dogood : dogood
Predict the output?
20
0
Compiler Error
none
Which of the following is/are true about constructors in Java?
1
1,2
1, 2, 4
1,2,3 & 4
output of the program
inside static block
a = 4
inside constructor
a = 11
Compiler Error
Run Time Error
inside static block
a = 4
inside constructor
a = 5
inside static block
a = 10
inside constructor
a = 11
What is the process of defining a method in a subclass having same name & type signature as a method in its superclass?
Method overloading
Method overriding
Method hiding
None of the mentioned
what is the output
9.0 9.0
9 9
compile time error
none
I am a Person
I am a Student
I am a Person I am a Student
I am a Student I am a Person
Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package?
Public
Protected
No Modifier
All of the mentioned
Which of these access specifiers can be used for a class so that its members can be accessed by a different class in the different package?
Public
Protected
Private
No Modifier
A package is a collection of
classes
interfaces
editing tools
classes and interfaces
