this.commission = commission;
superb(); commission = commission;
this.commission = commission; superb();
super(name, baseSalary); this.commission = commission;
super(); this.commission = commission;
this.commission = commission; super(name, baseSalary);
第1题:
Class TestException 1. public class TestException extends Exception { 2. } Class a: 1. public class a { 2. 3. public String sayHello(String name) throws TestException { 4. 5. if(name == null) { 6. throw new TestException(); 7. } 8. 9. return “Hello “+ name; 10. } 11. 12. } A programmer wants to use this code in an application: 45. A a=new A(); 46. System.out.println(a.sayHello(”John”)); Which two are true?()
第2题:
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”)后程序的输出是哪项?()
第3题:
1. public class returnIt ( 2. returnType methodA(byte x, double y) ( 3. return (short) x/y * 2; 4. ) 5. ) What is the valid returnType for methodA in line 2?()
第4题:
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?()
第5题:
1. class super { 2. public float getNum() {return 3.0f;} 3. } 4. 5. public class Sub extends Super { 6. 7. } Which method, placed at line 6, will cause a compiler error?()
第6题:
smith,SALES
null,SALES
smith,null
null,null
编译错误
第7题:
smith
null
SALES
编译错误
第8题:
BigDog() { super(); this(); }
BigDog() { String name = Fido; super(); }
BigDog() { super(); String name = Fido; }
private BigDog() { super();}
第9题:
smith
null
编译错误
name
第10题:
class Manager extends Employee{
public int getSalary(double x){}
}
class Manager extends Employee{
public double getSalary(int x,int y){}
}
class Manager extends Employee{
public double getSalary(){}
}
class Manager extends Employee{
public int getSalary(int x,int y){}
}
第11题:
static class InnerOne { public double methoda() { return d1; } }
static class InnerOne { static double methoda() { return d1; } }
private class InnerOne { public double methoda() { return d1; } }
protected class InnerOne { static double methoda() { return d1; } }
public abstract class InnerOne { public abstract double methoda(); }
第12题:
smith,SALES
null,SALES
smith,null
null,null
第13题:
1. public class A { 2. public void doit() { 3. } 4. public String doit() { 5. return “a”; 6. } 7. public double doit(int x) { 8. return 1.0; 9. } 10.} What is the result?()
第14题:
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”)后程序的输出是哪项?()
第15题:
我们定义一个Account类来描述银行账户,银行账户有账户名、金额等属性特征,同时有存款、取款等行为特征,下述代码适合描述的是哪项?()
第16题:
1. public class OuterClass { 2. private double d1 = 1.0; 3. // insert code here 4. } Which two are valid if inserted at line 3?()
第17题:
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?()
第18题:
Class a will not compile.
Line 46 can throw the unchecked exception TestException.
Line 45 can throw the unchecked exception TestException.
Line 46 will compile if the enclosing method throws a TestException.
Line 46 will compile if enclosed in a try block, where TestException is caught.
第19题:
An exception is thrown at runtime.
Compilation fails because of an error in line 7.
Compilation fails because of an error in line 4.
Compilation succeeds and no runtime errors with class A occur.
第20题:
The equals method does NOT properly override the Object.equals method.
Compilation fails because the private attribute p.name cannot be accessed in line 5.
To work correctly with hash-based data structures, this class must also implement the hashCode method.
When adding Person objects to a java.util.Set collection, the equals method in line 4 will prevent duplicates.
第21题:
Public float getNum() {return 4.0f; }
Public void getNum () { }
Public void getNum (double d) { }
Public double getNum (float d) {retrun 4.0f; }
第22题:
The code will compile without changes.
The code will compile if public Tree() { Plant(); } is added to the Tree class.
The code will compile if public Plant() { Tree(); } is added to the Plant class.
The code will compile if public Plant() { this(”fern”); } is added to the Plant class.
The code will compile if public Plant() { Plant(”fern”); } is added to the Plant class.
第23题:
this.commission = commission;
superb(); commission = commission;
this.commission = commission; superb();
super(name, baseSalary); this.commission = commission;
super(); this.commission = commission;
this.commission = commission; super(name, baseSalary);
第24题:
smith
null
SALES
编译错误