
Câu hỏi về kế thừa Java
Quiz
•
Fun
•
1st - 12th Grade
•
Practice Problem
•
Medium
Kiều Thị
Used 1+ times
FREE Resource
Enhance your content in a minute
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
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
15 questions
ISL 60th Anniversary Quiz Secondary School
Quiz
•
6th - 12th Grade
15 questions
The Land Of Stories: The wishing spell
Quiz
•
2nd - 12th Grade
18 questions
I totally get the 5 love languages!
Quiz
•
7th - 8th Grade
14 questions
Random Fun Questions
Quiz
•
6th - 8th Grade
20 questions
國中英語2下Review_2_
Quiz
•
7th - 9th Grade
11 questions
Classroom Expectation
Quiz
•
7th - 8th Grade
14 questions
Winter Holiday Quiz
Quiz
•
8th Grade
16 questions
1st Class Quiz
Quiz
•
1st Grade
Popular Resources on Wayground
10 questions
Forest Self-Management
Lesson
•
1st - 5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
30 questions
Thanksgiving Trivia
Quiz
•
9th - 12th Grade
30 questions
Thanksgiving Trivia
Quiz
•
6th Grade
11 questions
Would You Rather - Thanksgiving
Lesson
•
KG - 12th Grade
48 questions
The Eagle Way
Quiz
•
6th Grade
10 questions
Identifying equations
Quiz
•
KG - University
10 questions
Thanksgiving
Lesson
•
5th - 7th Grade
Discover more resources for Fun
30 questions
Thanksgiving Trivia
Quiz
•
9th - 12th Grade
30 questions
Thanksgiving Trivia
Quiz
•
6th Grade
11 questions
Would You Rather - Thanksgiving
Lesson
•
KG - 12th Grade
10 questions
Thanksgiving
Lesson
•
5th - 7th Grade
18 questions
Kids Christmas Trivia
Quiz
•
KG - 5th Grade
10 questions
Identify the Thanksgiving foods
Quiz
•
3rd - 4th Grade
12 questions
Thanksgiving Trivia
Quiz
•
3rd - 8th Grade
50 questions
Thanksgiving Fun
Quiz
•
3rd - 8th Grade
