网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
单选题
public class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return name; } } public class Manager extends Employee{ public Manager(String name){ System.out.println(getName()); } } 执行语句new Manager(“smith”)后程序的输出是哪项?()
A
smith
B
null
C
编译错误
D
name
参考答案
参考解析
解析:
暂无解析
更多 “单选题public class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return name; } } public class Manager extends Employee{ public Manager(String name){ System.out.println(getName()); } } 执行语句new Manager(“smith”)后程序的输出是哪项?()A smithB nullC 编译错误D name” 相关考题
考题
为使下列代码正常运行,应该在下划线处填入的选项是abstract class Person{public Person(String n)!name=n;}public____String getDescription();public String getName(){return name;}private String name;}A.staticB.privateC.abstractD.final
考题
阅读下列代码段 abstract class Person{ public Person(String n){ name=n; } public______String getDescription(); public String getName(){ } private String name; } 在下画线处应填入的修饰符是A.staticB.abstractC.protectedD.final
考题
阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。[说明]本程序的功能是给公司的员工Tom,Jack,Green增加薪水。三人的职位分别是programmer, Manager,CEO。程序由6个类组成:WorkerTest是主类,programmer,Manager,CEO三个类,薪水增加的规则是 programmer的涨幅是5%;Manager的是10%;CEO也是Manager,但是它除了有Manager的涨幅,还有1000元的bonus。接口SalaryRaise提供了一个增加薪水的方法raise()。[java程序]public class WorkerTest {public WorkerTest( ) {}public static void main( String[] args) {Programmer programmer = new Programmer( "Tom" ,3000);Manager manager = new Manager( "Jack" ,4000);CEO ceo = new CEO( "Green" ,4000);Worker [] worker = new Worker[3];programmer, raise( );manager, raise( );ceo. raise( );worker[0] = programmer;worker [1] = manager;worker[2] = ceo;for ( int i = 0 ;i < worker, length; i + + ) {System. out. prinfln (" Name:" + worker [i]. getName ( ) +" \ tSalary:" + worker [i]. getSalary ());public interface SalaryRaise { void raise( ); }public class Worker {public String name;public double (1);public Worker( ) {}public String getName( ) {return name;}public void setName( String name) {this. name = name;}public double getSalary( ) {return salary;}public void setSalary(double salary) { this. salary = salary; }}public class Programmer extends Worker implements (2) {public Programmer( ) {}public void raise( ) {double pets=0.05;double sala = this. getSalary( ) * (1 + pers);this. setSalary (sala);public Programmer( Siring name, double salary) tthis. name = name;this. salary = salary;public class Manager extends (3) implements SalaryRaise {public Manager( ) { }public Manager(String name, double salary) {this. name = name;this. salary = salary;}public void raise( ) {double pets = 0.1;double sala = this. getSalary() * (1 + pers);this. setSalary(sala);}}public class CEO extends Manager implements SalaryRaise {public CEO() {}public CEO( String name,double salary) {this. name = name;this. salary = salary;}public void raise( ) {double bonus = 1000;(4);double sala = this. getSalary( );(5);this. setSalary(sala);}}
考题
阅读下面代码 abstract class Person { public Person(String n) { name=n; } public______String getDescription(); public String getName() { return name; } private String name; } 在下画线处应填入的修饰符是A.staticB.abstractC.protectedD.final
考题
interface Playable {void play();}interface Bounceable {void play();}interface Rollable extends Playable, Bounceable {Ball ball = new Ball("PingPang");}class Ball implements Rollable {private String name;public String getName() {return name;}public Ball(String name) {this.name = name;}public void play() {ball = new Ball("Football");System.out.println(ball.getName());}}这个错误不容易发现。
考题
为使下列代码正常运行,应该在下画线处填入的选项是( )。 abstract class person{ public Person(String n){ name=n: } Public String getDescription; public String getName{ return name; } private string name; }A.staticB.privateC.abstractD.final
考题
执行以下代码后,下面哪些描述是正确的() public class Student{ private String name = “Jema”; public void setName(String name){ this.name = name; } public String getName(){ return this.name; } public static void main(String[] args){ Student s; System.out.println(s.getName()); } }A、输出nullB、第10行编译报错C、第11行编译报错D、输出Jema
考题
1. public class Employee { 2. String name; 3. double baseSalary; 4. Employee(String name, double baseSalary) { 5. this.name = name; 6. this.baseSalary = baseSalary; 7. } 8. } And: 1. public class Salesperson extends Employee { 2. double commission; 3. public Salesperson(String name, double baseSalary, 4. double commission) { 5. // insert code here 6. } 7. } Which code, inserted at line 7, completes the Salesperson constructor?() A、 this.commission = commission;B、 superb(); commission = commission;C、 this.commission = commission; superb();D、 super(name, baseSalary); this.commission = commission;E、 super(); this.commission = commission;F、 this.commission = commission; super(name, baseSalary);
考题
public class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return name; } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ this.department = department; super(name); (应于上一行掉位置) System.out.println(getName()); } } Super的位置是否在方法的首行 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A、 smithB、 nullC、 SALESD、 编译错误
考题
public class Pet{ private String name; public Pet(String name){ this.name = name; } public void speak(){ System.out.print(name); } } public class Dog extends Pet{ public Dog(String name){ super(name); } public void speak(){ super.speak(); System.out.print(“ Dog ”); } } 执行代码 Pet pet = new Dog(“京巴”); pet.speak(); 后输出的内容是哪项?() A、 京巴B、 京巴 DogC、 nullD、 Dog京巴
考题
public class Employee{ private String name; public Employee(String name){ this.name = name; } public void display(){ System.out.print(name); } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ super(name); this.department = department; } public void display(){ System.out.println(super.display()+”,”+department); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?() A、 smith,SALESB、 null,SALESC、 smith,nullD、 null,nullE、 编译错误
考题
public class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return name; } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ this.department = department; super(name); System.out.println(getName()); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?() A、 smithB、 nullC、 SALESD、 编译错误
考题
public class Employee{ private String name; public Employee(String name){ this.name = name; } public void display(){ System.out.print(name); } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ super(name); this.department = department; } public void display(){ System.out.println( super.display()+”,”+department); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?() A、 smith,SALESB、 null,SALESC、 smith,nullD、 null,null
考题
public class Plant { private String name; public Plant(String name) { this.name = name; } public String getName() { return name; } } public class Tree extends Plant { public void growFruit() { } public void dropLeaves() { } } Which is true?() A、 The code will compile without changes.B、 The code will compile if public Tree() { Plant(); } is added to the Tree class.C、 The code will compile if public Plant() { Tree(); } is added to the Plant class.D、 The code will compile if public Plant() { this(”fern”); } is added to the Plant class.E、 The code will compile if public Plant() { Plant(”fern”); } is added to the Plant class.
考题
11. class Person { 12. String name = “No name‟; 13. public Person(String nm) { name = nm; } 14. } 15. 16. class Employee extends Person { 17. String emplD = “0000”; 18. public Employee(String id) { empID = id; } 19. } 20. 21. public class EmployeeTest { 22. public static void main(String[] args) { 23. Employee e = new Employee(”4321”); 24. System.out.println(e.empID); 25. } 26. } What is the result?() A、 4321B、 0000C、 An exception is thrown at runtime.D、 Compilation fails because of an error in line 18.
考题
public class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return name; } } public class Manager extends Employee{ public Manager(String name){ System.out.println(getName()); } } 执行语句new Manager(“smith”)后程序的输出是哪项?() A、 smithB、 nullC、 编译错误D、 name
考题
public class NamedCounter { private final String name; private int count; public NamedCounter(String name) { this.name = name; } public String getName() { return name; } public void increment() { coount++; } public int getCount() { return count; } public void reset() { count = 0; } } Which three changes should be made to adapt this class to be used safely by multiple threads? ()A、 declare reset() using the synchronized keywordB、 declare getName() using the synchronized keywordC、 declare getCount() using the synchronized keywordD、 declare the constructor using the synchronized keywordE、 declare increment() using the synchronized keyword
考题
单选题public class Pet{ private String name; public Pet(){ System.out.print(1); } public Pet(String name){ System.out.print(2); } } public class Dog extends Pet{ public Dog(){ System.out.print(4); } public Dog(String name){ super(name); System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?()A
33B
13C
23D
123
考题
单选题public class Employee{ private String name; public Employee(String name){ this.name = name; } public void display(){ System.out.print(name); } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ super(name); this.department = department; } public void display(){ System.out.println(super.display()+”,”+department); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A
smith,SALESB
null,SALESC
smith,nullD
null,nullE
编译错误
考题
单选题11. class Person { 12. String name = “No name‟; 13. public Person(String nm) { name = nm; } 14. } 15. 16. class Employee extends Person { 17. String emplD = “0000”; 18. public Employee(String id) { empID = id; } 19. } 20. 21. public class EmployeeTest { 22. public static void main(String[] args) { 23. Employee e = new Employee(”4321”); 24. System.out.println(e.empID); 25. } 26. } What is the result?()A
4321B
0000C
An exception is thrown at runtime.D
Compilation fails because of an error in line 18.
考题
单选题public class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return name; } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ this.department = department; super(name); System.out.println(getName()); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A
smithB
nullC
SALESD
编译错误
考题
单选题public class Employee{ private String name; public Employee(String name){ this.name = name; } public void display(){ System.out.print(name); } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ super(name); this.department = department; } public void display(){ System.out.println( super.display()+”,”+department); } } 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A
smith,SALESB
null,SALESC
smith,nullD
null,null
考题
单选题public class Plant { private String name; public Plant(String name) { this.name = name; } public String getName() { return name; } } public class Tree extends Plant { public void growFruit() { } public void dropLeaves() { } } Which is true?()A
The code will compile without changes.B
The code will compile if public Tree() { Plant(); } is added to the Tree class.C
The code will compile if public Plant() { Tree(); } is added to the Plant class.D
The code will compile if public Plant() { this(”fern”); } is added to the Plant class.E
The code will compile if public Plant() { Plant(”fern”); } is added to the Plant class.
考题
单选题public class Pet{ private String name; public Pet(String name){ this.name = name; } public void speak(){ System.out.print(name); } } public class Dog extends Pet{ public Dog(String name){ super(name); } public void speak(){ super.speak(); System.out.print(“ Dog ”); } } 执行代码 Pet pet = new Dog(“京巴”); pet.speak(); 后输出的内容是哪项?()A
京巴B
京巴 DogC
nullD
Dog京巴
考题
单选题执行以下代码后,下面哪些描述是正确的() public class Student{ private String name = “Jema”; public void setName(String name){ this.name = name; } public String getName(){ return this.name; } public static void main(String[] args){ Student s; System.out.println(s.getName()); } }A
输出nullB
第10行编译报错C
第11行编译报错D
输出Jema
考题
单选题public class Employee{ private String name; public Employee(String name){ this.name = name; } public String getName(){ return name; } } public class Manager extends Employee{ private String department; public Manager(String name,String department){ this.department = department; super(name); (应于上一行掉位置) System.out.println(getName()); } } Super的位置是否在方法的首行 执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()A
smithB
nullC
SALESD
编译错误
考题
单选题1. public class Employee { 2. String name; 3. double baseSalary; 4. Employee(String name, double baseSalary) { 5. this.name = name; 6. this.baseSalary = baseSalary; 7. } 8. } And: 1. public class Salesperson extends Employee { 2. double commission; 3. public Salesperson(String name, double baseSalary, 4. double commission) { 5. // insert code here 6. } 7. } Which code, inserted at line 7, completes the Salesperson constructor?()A
this.commission = commission;B
superb(); commission = commission;C
this.commission = commission; superb();D
super(name, baseSalary); this.commission = commission;E
super(); this.commission = commission;F
this.commission = commission; super(name, baseSalary);
热门标签
最新试卷