
Câu hỏi về kế thừa Java

Quiz
•
Fun
•
1st - 12th Grade
•
Medium
Kiều Thị
Used 1+ times
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Kết quả của đoạn mã sau in ra như thế nào?
class Employee {
float salary = 1000;
}
class Programmer extends Employee {
int bonus = 150;
}
public class InheritanceSample1 {
public static void main(String args[]) {
Programmer p = new Programmer();
System.out.println("Programmer salary is: " + p.salary);
System.out.println("Bonus of Programmer is: " + p.bonus);
}
}
Programmer salary is: 1000.0 Bonus of Programmer is: 150
Lỗi biên dịch do không thể khai báo Programmer p = new Programmer();
Lỗi dòng in p.salary do Programmer không có salary
Programmer salary is: 1000.0 Bonus of Programmer is: 150.0
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Kết quả của đoạn mã sau in ra như thế nào?
class Animal {
void eat() {
System.out.println("eating...");
}
}
class Dog extends Animal {
void bark() {
System.out.println("barking...");
}
}
public class TestInheritance1 {
public static void main(String args[]) {
Animal d = new Dog();
d.bark();
d.eat();
}
}
eating... barking...
Lỗi biên dịch do không thể khai báo Animal d = new Dog();
barking... eating...
Lỗi biên dịch dòng d.bark
3.
MULTIPLE SELECT QUESTION
30 sec • 1 pt
Kết luận nào sau đây đúng:
class A {
private int data = 40;
private void msg() {
System.out.println("Hello Java");
}
}
public class Simple {
public static void main(String args[]) {
A obj = new A();
System.out.println(obj.data);
obj.msg();
}
}
40 Hello Java
Lỗi biên dịch dòng obj.data
Lỗi biên dịch dòng obj.msg()
Không có kết luận đúng
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Kết luận nào sau đây đúng:
package com.codegym.demo1;
class A {
void msg() {
System.out.println("Hello");
}
}
package com.codegym.demo2;
import com.codegym.demo1;
public class B {
public static void main(String args[]) {
A obj = new A();
obj.msg();
}
}
Kết quả là Hello
Lỗi biên dịch dòng A obj = new A();
Lỗi biên dịch dòng obj.msg();
Không có kết luận đúng
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Kết luận nào sau đây đúng:
package com.codegym.demo1;
public class A {
void msg() {
System.out.println("Hello");
}
}
package com.codegym.demo2;
import com.codegym.demo1;
public class B extends A {
public static void main(String args[]) {
A obj = new A();
obj.msg();
}
}
Kết quả là Hello
Lỗi biên dịch dòng A obj = new A();
Lỗi biên dịch dòng obj.msg();
Không có kết luận đúng
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Kết quả của chương trình in ra là gì?
class Vehicle {
int speed = 50;
}
public class Bike extends Vehicle {
int speed = 100;
void display() {
System.out.println(speed);
}
public static void main(String args[]) {
Bike b = new Bike();
b.display();
}
}
100
50
Lỗi biên dịch
Không có kết luận đúng
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Kết quả của chương trình in ra là gì?
class Vehicle {
int speed = 50;
}
public class Bike extends Vehicle {
int speed = 100;
void display() {
System.out.println(super.speed);
}
public static void main(String args[]) {
Bike b = new Bike();
b.display();
}
}
100
50
Lỗi biên dịch
Không có kết luận đúng
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
Roblox Bedwars Quiz

Quiz
•
KG - 12th Grade
12 questions
NFL FACTS

Quiz
•
KG - University
10 questions
Bed Wars

Quiz
•
KG - Professional Dev...
11 questions
NFL quiz

Quiz
•
KG - 2nd Grade
12 questions
Repaso Flujo

Quiz
•
5th Grade
13 questions
Honkai Impact quiz

Quiz
•
4th - 12th Grade
20 questions
3D Printer Assessment

Quiz
•
6th - 8th Grade
10 questions
League of Legends Trivia

Quiz
•
1st Grade - Professio...
Popular Resources on Wayground
10 questions
SR&R 2025-2026 Practice Quiz

Quiz
•
6th - 8th Grade
30 questions
Review of Grade Level Rules WJH

Quiz
•
6th - 8th Grade
6 questions
PRIDE in the Hallways and Bathrooms

Lesson
•
12th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
15 questions
Subtracting Integers

Quiz
•
7th Grade
Discover more resources for Fun
15 questions
Let's Take a Poll...

Quiz
•
9th Grade - University
15 questions
Fast food

Quiz
•
7th Grade
15 questions
fun?

Quiz
•
8th Grade
10 questions
Fact Check Ice Breaker: Two truths and a lie

Quiz
•
5th - 12th Grade
20 questions
Guess The Cartoon!

Quiz
•
7th Grade
5 questions
Responsibility in the Classroom

Quiz
•
6th Grade
16 questions
Do You Know WHMS?

Quiz
•
6th Grade
12 questions
Disney Trivia

Lesson
•
5th - 12th Grade