题目内容

若有如下类的定义 class Father{int a; public Father(){} } class Son extends Father{int b;} 则下面描述正确的选项是( )

A. Son类中仅包含成员变量b
B. Son类中仅包含成员变量a和b
C. Son类中仅包含成员变量a和b 、以及成员方法Father
D. Father类中包含成员变量a和b

查看答案
更多问题

已知类关系如下: class Employee{} class Manager extends Employee{} class Director extends Employee{} 则下列语句正确的是( )

A. Employee e=new Manager();
B. Director d=new Manager();
C.Director d =new Employee ();
D. Manager m=new Director ();

若有如下程序: class Employee{private int a=1;} class Manager extends Employee{ int b=2; public void show(){ System.out.print(a); }} class MainDemo{ public static void main(String []args){ Manager m = new Manager(); m.show(); System.out.print(m.b); }} 则程序运行结果是( )

A. 3
B. 12
C. 编译错误
D. 结果不确定

若有以下程序: class Employee{ public void show(int i){} //① public void show(int i,int j){} //② } class Manager extends Employee{ public void show(){} //③ public void show(int i){} //④ } 则下面描述错误的是( )

A. 语句 ①与语句 ③是方法重载
B. 语句 ①与语句④是方法覆盖
C. 语句②与语句③是方法重载
D. 语句②与语句④是方法覆盖

若有以下程序: class Employee{ public void show(){ System.out.print(“1”);} } class Manager extends Employee{ public void show(){ System.out.print(“2”);} } class MainDemo{ public static void main(String []args){ Manager m = new Manager(); m.show(); }} 则程序运行结果为( )

A. 1
B. 2
C. 12
D. 无法确定

答案查题题库