NEW
Font size
WorksheetsOops moment/1
Total questions: 13
Worksheet time: 14mins
Which keyword is used to inherit a class in Java?
Implements
Inherits
Extends
Super
Which is the correct way to create an object of class Dog?
Dog d = Dog();
Dog d = new Dog;
Dog d = new Dog();
Dog = new d();
Which keyword refers to the current object?
this
super
final
extends
What does method overloading mean?
Using multiple classes
Creating methods with same name but different parameters
Calling one method from another
Using one method in multiple classes
What keyword is used to call a parent class constructor?
parent
this
extends
super
What does the final keyword do when applied to a class?
It prevents inheritance
It allows only static methods
It makes the class abstract
It allows method overriding
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();
}
}
Animal sound
Bark
Error
Nothing
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();
}
}
5
10
Error
Null
public class Main {
public static void main(String[] args) {
String str = "One" + 1 + 2 + 3;
System.out.println(str);
}
}
One123
One6
6One
Error
Which of the following is TRUE about static methods in Java?
They can access instance variables directly
They must be called using an object
They can be called without creating an object
They are automatically abstract
wear many faces but remain the same at heart. What am I?
Encapsulation
Abstraction
Polymorphism
Class
“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?"
Abstraction
Inheritance
Polymorphism
Encapsulation
"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?"
Function oriented programming
Object oriented programming (oop)
Class
Inheritance
