已有如下程序:
class Person{
private int a;
public void change(int m){a=m;}
}
public class Teacher extends Person {
public int b;
public static void main(String args[]){
Person p=new Person();
Teacher t=new Teacher();
int i;
_____________________
}
}
下面划线处填写的语句那些是非法的操作
提示:考查内容包括静态成员,私有成员,继承等知识点
class Person{
private int a;
public void change(int m){a=m;}
}
public class Teacher extends Person {
public int b;
public static void main(String args[]){
Person p=new Person();
Teacher t=new Teacher();
int i;
_____________________
}
}
下面划线处填写的语句那些是非法的操作
提示:考查内容包括静态成员,私有成员,继承等知识点
举一反三
- class Person {private int a;public int change(int m){ return m; }}public class Teacher extends Person {public int b;public static void main(String arg[]){Person p = new Person();Teacher t = new Teacher();int i;// point x}}在 // point x安排哪个语句合法?
- 在下列程序的划线处应填入的语句是class Person { private int a;}public class Man extends Person{ public int b; public static void main (String arg []){ Person p=new Person(); Man t=new Man(); int i: }} A.i=w; B.i=b C.i=p.a; D.i=t.b;
- 分析下面的程序,输出的结果是? public class Test { public static void main(String[] args) { final Person p = new Person("张三", 23); p.setName("李四"); p.setAge(24); System.out.println(p); } } class Person { private String name; private int age; public Person() { super(); } public Person(String name, int age) { super(); this.name = name; this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } @Override public String toString() { return "我的姓名是:" + name + ",我的年龄是:" + age ; } }
- class Person{} class Student extends Person{ public int id; public int score; public String name; public int getScore() { return score; }
- 中国大学MOOC: 下列程序的运行结果是______。public class Person {static int arr[ ]=new int[10];public static void main(String args ) { System.out.println(arr[9]);}}