PRO192_-_REB5_-_FA_2023_1330.webp
lanhong87

PRO192_-_REB5_-_FA_2023_1330.webp

Answer (Choose 1 answer)

This question concerns the following class definition:
1. package one;
2.
3. public class Bird {
4.protected static int k = 0;
45670 6.7.
5.public Bird() { k++; }
protected void fly() {}
8.}static int getValue() { return(k); }
Which statement is true about class Bird and the following class Grebe?
1. package two;
2.
3. class Parrot extends one. Bird {
4.Parrot() { k++; }
5.
6.public static void main(String args[]) { System.out.print("Before: " + k);
7.
8.Parrot x = new Parrot();
9.10.System.out.println(" After: " + k);
x.fly();
11. }
12.}
A. The program will compile and execute. The output will be Before: 0 After: 2.
B. The program will compile and execute. The output will be Before: 0 After: 1.
C. Compilation of Parrot will fail at line 4 because static members cannot be overridden.
ID Compilation of Parrot will fail at line 10 because method flv() is protected in the superclass
Exit 20

Thông tin

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

Image metadata

Filename
PRO192_-_REB5_-_FA_2023_1330.webp
File size
69.8 KB
Dimensions
1542px x 690px

Share this media

Back
Bên trên Bottom