wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Oops moment/1

Total questions: 13

Worksheet time: 14mins

Name
Class
Date
1.

Which keyword is used to inherit a class in Java?

a)

Implements

b)

Inherits

c)

Extends

d)

Super

2.

Which is the correct way to create an object of class Dog?

a)

Dog d = Dog();

b)

Dog d = new Dog;

c)

Dog d = new Dog();

d)

Dog = new d();

3.

Which keyword refers to the current object?

a)

this

b)

super

c)

final

d)

extends

4.

What does method overloading mean?

a)

Using multiple classes

b)

Creating methods with same name but different parameters

c)

Calling one method from another

d)

Using one method in multiple classes

5.

What keyword is used to call a parent class constructor?

a)

parent

b)

this

c)

extends

d)

super

6.

What does the final keyword do when applied to a class?

a)

It prevents inheritance

b)

It allows only static methods

c)

It makes the class abstract

d)

It allows method overriding

7.

class Animal {

void sound() {

System.out.println("Animal sound");

}

}

class Dog extends Animal {

void sound() {

System.out.println("Bark");

}

}

public class Main {

public static void main(String[] args) {

Animal a = new Dog();

a.sound();

}

}

a)

Animal sound

b)

Bark

c)

Error

d)

Nothing

8.

class A {

int x = 5;

}

class B extends A {

int x = 10;

void print() {

System.out.println(super.x);

}

}

public class Main {

public static void main(String[] args) {

B obj = new B();

obj.print();

}

}

a)

5

b)

10

c)

Error

d)

Null

9.

public class Main {

public static void main(String[] args) {

String str = "One" + 1 + 2 + 3;

System.out.println(str);

}

}

a)

One123

b)

One6

c)

6One

d)

Error

10.

Which of the following is TRUE about static methods in Java?

a)

They can access instance variables directly

b)

They must be called using an object

c)

They can be called without creating an object

d)

They are automatically abstract

11.

wear many faces but remain the same at heart. What am I?

a)

Encapsulation

b)

Abstraction

c)

Polymorphism

d)

Class

12.

“I lock the data, hide the key,
And guard the code quite privately.
I wrap it all in tidy form,
And shield from any outer storm.
What am I?"

a)

Abstraction

b)

Inheritance

c)

Polymorphism

d)

Encapsulation

13.

"I’m built on classes, blueprints true,
I mold real-world things for you.
With state and behavior I come alive,
With four big pillars, I survive.
What am I?"

a)

Function oriented programming

b)

Object oriented programming (oop)

c)

Class

d)

Inheritance