Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

QUIZ: Object Oriented Programming with JAVA

Date:20/03/2024 Duration: 30 Mins Max Marks: 10


1. Tick true or false.
1 JVM is platform independent
2 static methods cannot be overridden
3 new operator allocates memory during compile-time
4 Static methods can be called using class name
5 The preferred method to create thread is to extend Thread class

2. Fill in the Blanks


1 A user can create his own exception class by extending __________ class
2 The data members of interface are by default ____
3 Default Layout Manager for Frame is ________________________
4 A key word __________________ prevents method overriding
5 What type exceptions do not require try-catch blocks? ____________

3. Predict OutPut of the following


1
If ‘wtBox’ class inherits from ‘Box’ , write valid 4. public class A {
public static void main(String []
statements.
args) {
a) Box b=new Box(); c) wtBox w=new wtBox();
for(int x = 0; x < args.length;
b) Box b1=new wtBox(); d) wtBox w1=new Box(); x++) {
e) Object obj=new Box(); System.out.print(args[x] + " ");
2 }}}
try {int a=4/0;} and two separate command line invocations:
catch(Exception e) java A
{System.out.print(“catch msg”);} java A 1 2 3 4 What is output?

finally
{ System.out.println(“finally msg”);}
3
abstract class Vehicle { public int speed() { 5. class Test
return 0; } {
class Car extends Vehicle { public int speed() static int x;
{ return 60; }
public:
class RaceCar extends Car { public int speed()
Test() { x++; }
{ return 150; } ...
static int getX() {return x;}
RaceCar racer = new RaceCar();
RaceCar racerCar = new Car();
};
Vehicle vehicle = new RaceCar(); int Test::x = 0;
System.out.println(racer.speed() + ", " + int main(){
raceCar.speed() + ", " + vehicle.speed()); cout << Test::getX() << " ";
What is the result? Test t[5];
A. 0, 0, 0 cout << Test::getX();
B. 150, 60, 0 }
C. Compilation fails.
a. Compiler error
D. 150, 150, 150
E. An exception is thrown at runtime. b. 0 0 0
c. 5 5
d. 0 5

You might also like