Worksheetsquiz oop [encapsulation, inherit, interface, abstract]
Total questions: 50
Worksheet time: 31mins
Apa output dari program di atas?
Animal makes a sound, Dog barks
Dog barks, Animal makes a sound
Animal makes a sound, Animal makes a sound
Dog barks, Dog barks
Apa output dari program di atas?
Drawing Shape
Drawing Circle
Compiler Error
Runtime Error
Apa output dari program di atas?
Car is moving, Bike is moving
Bike is moving, Car is moving
Car is moving, Car is moving
Bike is moving, Bike is moving
Apa output dari program di atas?
Parent class
Child class
Compiler Error
Runtime Error
Apa output dari program di atas?
Base
Derived
AnotherDerived
Compiler Error
apa kode yang tepat agar output seperti ini: "Dog barks"
Animal a = new Dog();
a.makeSound();
Animal a = new Cat();
a.makeSound();
Dog d = new Animal();
d.makeSound();
Cat c = new Animal();
c.makeSound();
apa kode yang tepat untuk menerapkan enkapsulasi pada kelas di atas?
public void setName(String name) { this.name = name; }
public String getName() { return name; }
public void setAge(int age) { this.age = age; }
public int getAge() { return age; }
public String name;
public int age;
public String getName() { return name; }
apa kode yang tepat agar kelas Dog mengimplementasikan interface Animal?
public void eat() { System.out.println("Dog eats"); }
public void sleep() { System.out.println("Dog sleeps"); }
public void eat() { System.out.println("Animal eats"); }
public void sleep() { System.out.println("Animal sleeps"); }
public void run() { System.out.println("Dog runs"); }
public void eat() { System.out.println("Dog eats"); }
apa kode yang tepat agar kelas Car mengimplementasikan metode abstract start?
void start() { System.out.println("Car starts"); }
void start() { System.out.println("Vehicle starts"); }
void stop() { System.out.println("Car stops"); }
void run() { System.out.println("Car runs"); }
apa kode yang tepat agar kelas Child mengoverride metode display?
void display() { System.out.println("Child class"); }
void show() { System.out.println("Child class"); }
void display() { System.out.println("Parent class"); }
void show() { System.out.println("Parent class"); }
