已知</p></p><p><p> import java.io.*;</p></p><p><p>class Person{</p></p><p><p>public static void print(){System.out.print("Person");}</p></p><p><p>}</p></p><p><p> class Employee extends Person{</p></p><p><p> public void print(){</p></p><p><p> System.out.print("Employee");}</p></p><p><p>}</p></p><p><p>class Manager extends Employee{</p></p><p><p> public void print(){</p></p><p><p> System.out.print("Manager");}</p></p><p><p>}</p></p><p><p>public class Test{</p></p><p><p> public static void main(String[] args){</p></p><p><p> Manager man = new Manager();</p></p><p><p> Employee emp1 = new Employee();</p></p><p><p> Employee emp2 = (Employee)man;</p></p><p><p> Person person = (Person)man;</p></p><p><p> emp2.print();</p></p><p><p> System.out.print("#");</p></p><p><p> person.print();}</p></p><p><p>}</p></p><p><p>对于以上代码,其输出结果是</p></p>
已知</p></p><p><p> import java.io.*;</p></p><p><p>class Person{</p></p><p><p>public static void print(){System.out.print("Person");}</p></p><p><p>}</p></p><p><p> class Employee extends Person{</p></p><p><p> public void print(){</p></p><p><p> System.out.print("Employee");}</p></p><p><p>}</p></p><p><p>class Manager extends Employee{</p></p><p><p> public void print(){</p></p><p><p> System.out.print("Manager");}</p></p><p><p>}</p></p><p><p>public class Test{</p></p><p><p> public static void main(String[] args){</p></p><p><p> Manager man = new Manager();</p></p><p><p> Employee emp1 = new Employee();</p></p><p><p> Employee emp2 = (Employee)man;</p></p><p><p> Person person = (Person)man;</p></p><p><p> emp2.print();</p></p><p><p> System.out.print("#");</p></p><p><p> person.print();}</p></p><p><p>}</p></p><p><p>对于以上代码,其输出结果是</p></p>
执行以下程序段,输出的结果为_______。class Person: def __del__(self): print("--del--")person = Person()del personprint("--end--") A: --del-- B: --end-- C: --del----end-- D: 以上三项均是错误的
执行以下程序段,输出的结果为_______。class Person: def __del__(self): print("--del--")person = Person()del personprint("--end--") A: --del-- B: --end-- C: --del----end-- D: 以上三项均是错误的
定义类的代码如下:class Person():def __init__(self,name):self.name=namedef show(self):print(self.name) A: p=Personp.show() B: p=Person()p.show('李思') C: p=Person('李思')p.show() D: p=Person('李思')show()
定义类的代码如下:class Person():def __init__(self,name):self.name=namedef show(self):print(self.name) A: p=Personp.show() B: p=Person()p.show('李思') C: p=Person('李思')p.show() D: p=Person('李思')show()
class Person: def __init__(self,name):self.name=name def __str__(self):return "我的名字是"+self.nameperson=Person("小明")print(person)编译能通过吗,如果通过写出结果,否则写出失败原因
class Person: def __init__(self,name):self.name=name def __str__(self):return "我的名字是"+self.nameperson=Person("小明")print(person)编译能通过吗,如果通过写出结果,否则写出失败原因
import java.io.*; class Person{ public void print(){System.out.print("Person ");} public void printMyGender(String s){ this.print(); System.out.print(s+" "); } } class Gender{ String type="gender"; public void print(Person p){p.printMyGender(type);} } class Female extends Gender{ public Female(){ type="female"; } } class Male extends Gender{ public Male(){ type="male"; } } class Employee extends Person{ public void print(){ System.out.print("Employee ");} } class Manager extends Employee{ public void print(){ System.out.print("Manager ");} } public class Test{ public static void main(String[] args){ Manager man = new Manager(); Employee em = new Employee(); Gender gender1 = new Male(); Gender gender2 = new Female(); gender1.print(man); gender2.print(em); } } 对于以上代码,其运行结果是
import java.io.*; class Person{ public void print(){System.out.print("Person ");} public void printMyGender(String s){ this.print(); System.out.print(s+" "); } } class Gender{ String type="gender"; public void print(Person p){p.printMyGender(type);} } class Female extends Gender{ public Female(){ type="female"; } } class Male extends Gender{ public Male(){ type="male"; } } class Employee extends Person{ public void print(){ System.out.print("Employee ");} } class Manager extends Employee{ public void print(){ System.out.print("Manager ");} } public class Test{ public static void main(String[] args){ Manager man = new Manager(); Employee em = new Employee(); Gender gender1 = new Male(); Gender gender2 = new Female(); gender1.print(man); gender2.print(em); } } 对于以上代码,其运行结果是
class Person: def __init__(self,n="xxx"): self.name=n class Student(Person): def __init__(self,s="male"): self.sex=s def show(self): print(self.name,self.sex) s=Student("female") s.show() 结果:
class Person: def __init__(self,n="xxx"): self.name=n class Student(Person): def __init__(self,s="male"): self.sex=s def show(self): print(self.name,self.sex) s=Student("female") s.show() 结果:
class Person:def __init__(self,n="xxx"):self.name=nclass Student(Person):def __init__(self,s="male"):self.sex=sdef show(self):print(self.name,self.sex)s=Student("female")s.show()结果: A: xxx male B: xxx C: 结果错误 D: xxx female
class Person:def __init__(self,n="xxx"):self.name=nclass Student(Person):def __init__(self,s="male"):self.sex=sdef show(self):print(self.name,self.sex)s=Student("female")s.show()结果: A: xxx male B: xxx C: 结果错误 D: xxx female
【多选题】定义了如下Person类,下面()程序段能够正确初始化Person数组。 class Person{ private String name; public Person(String name){ this.name=name; } } A. Person [ ] list=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")}; B. Person list[ ]=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")}; C. Person[ ] list={new Person("孙悟空"),new Person("猪八戒")}; D. Person list=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")};
【多选题】定义了如下Person类,下面()程序段能够正确初始化Person数组。 class Person{ private String name; public Person(String name){ this.name=name; } } A. Person [ ] list=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")}; B. Person list[ ]=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")}; C. Person[ ] list={new Person("孙悟空"),new Person("猪八戒")}; D. Person list=new Person[ ]{new Person("孙悟空"),new Person("猪八戒")};
下面程序运行的结果是( )。class Person:def __init__(self,n="张三"): self.name=nclass Student(Person):def __init__(self,s="male"):self.sex=sdef show(self):print(self.name,self.sex)s=Student("female")s.show() A: 张三 male B: 张三 female C: 出错 D: 张三
下面程序运行的结果是( )。class Person:def __init__(self,n="张三"): self.name=nclass Student(Person):def __init__(self,s="male"):self.sex=sdef show(self):print(self.name,self.sex)s=Student("female")s.show() A: 张三 male B: 张三 female C: 出错 D: 张三
print(‘print(“print”)’)输出结果是()。 A: 错误消息 B: ’print(“print”)’ C: print(“print”)
print(‘print(“print”)’)输出结果是()。 A: 错误消息 B: ’print(“print”)’ C: print(“print”)