PRO192_-_SP_2024_-_Block_5_-_FE_1921.webp
K

PRO192_-_SP_2024_-_Block_5_-_FE_1921.webp

Multiple Choices
Answer (Choose 1 answer)
What will happen when you attempt to compile and run the following program:
abstract class A {
int x=5;
void foo() {
System.out.print(x);
}
}
class B extends A {
int y=7;
void foo() {
System.out.print(x+y);
} }
class Main {
public static void main(String[] args) {
A t = new B(); // (*)
t.foo();
}
A. The output of the program is 12
B. The output of the program is 7
C. The output of the program is 5
D. The code line (*) causes a compile-time error.

Thông tin

Category
PRO192
Thêm bởi
Kurourushi89
Ngày thêm
Lượt xem
6,229
Lượt bình luận
23
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom