Inconceivable!
Dizzying intellect!
The code runs with no output.
An exception is thrown at runtime.
Compilation fails because of an error in line 22.
第1题:
如果有一个类MyFrame是Frame的子类,但它不能被实例化,请写出该类的声明头为( )。
A.abstract class Frame. extends MyFrame
B.abstract class MyFrame. extends Frame
C.class MyFrame. abstract extends Frame
D.class Frame. abstract extends MyFrame.
第2题:
此题为判断题(对,错)。
第3题:
In which two cases does the compiler supply a default constructor for class A?()
第4题:
10. abstract public class Employee { 11. protected abstract double getSalesAmount(); 12. public double getCommision() { 13. return getSalesAmount() * 0.15; 14. } 15. } 16. class Sales extends Employee { 17. // insert method here 18. } Which two methods, inserted independently at line 17, correctly complete the Sales class?()
第5题:
现在有两个类A、B,以下描述中表示B继承自A的是()
第6题:
现自: 1. interface Color { } 2. interface Weight { } 3. //insert code here 和以下足六个声明: class Boat extends Color, extends Weight { } class Boat extends Color and Weight { } class Boat extends Color, Weight { } class Boat implements Color, implements Weight { } class Boat implements Color and Weight { } class Boat implements Color, Weight { } 分别插入到第3行,有多少行可以编译? ()
第7题:
What produces a compiler error?()
第8题:
10. interface Foo {} 11. class Alpha implements Foo {} 12. class Beta extends Alpha {} 13. class Delta extends Beta { 14. public static void main( String[] args) { 15. Beta x = new Beta(); 16. // insert code here 17. } 18. } Which code, inserted at line 16, will cause a java.lang.ClassCastException?()
第9题:
public void foo() { /* more code here */ }
private void foo() { /* more code here */ }
protected void foo() { /* more code here */ }
int foo() { /* more code here */ }
void foo() { /* more code here */ }
第10题:
Inconceivable!
Dizzying intellect!
The code runs with no output.
An exception is thrown at runtime.
Compilation fails because of an error in line 22.
第11题:
public interface Person { } public class Employee extends Person { }
public interface Shape { } public class Employee extends Shape { }
public interface Color { } public class Employee extends Color { }
public class Species { } public class Animal (private Species species;)
interface Component { } Class Container implements Component ( Private Component[ ] children; )
第12题:
0, 0,0
150, 60, 0
Compilation fails.
150, 150, 150
An exception is thrown at runtime.
第13题:
定义一个类名为MyClass的类,并且该类可被所有类访问,那么该类的正确声明应为()
A、private class MyClass extends Object
B、class MyClass extends Object
C、public class MyClass
D、protected class MyClass extends Object
第14题:
10. public class ClassA { 11. public void count(int i) { 12. count(++i); 13. } 14. } And: 20. ClassA a = new ClassA(); 21. a.count(3); Which exception or error should be thrown by the virtual machine?()
第15题:
10. class Line { 11. public static class Point { } 12. } 13. 14. class Triangle { 15. // insert code here 16. } Which code, inserted at line 15, creates an instance of the Point class defined in Line?()
第16题:
Assume that country is set for each class. Given: 10. public class Money { 11. private String country, name; 12. public getCountry() { return country; } 13.} and: 24. class Yen extends Money { 25. public String getCountry() { return super.country; } 26. } 27. 28. class Euro extends Money { 29. public String getCountry(String timeZone) { 30. return super.getCountry(); 31. } 32. } Which two are correct?()
第17题:
定义一个类名为"MyClass.java"的类,并且该类可被一个工程中的所有类访问,那么该类的正确声明应为()。
第18题:
下列类的定义中,错误的是()。
第19题:
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?()
第20题:
1. class Exc0 extends Exception { } 2. class Exc1 extends Exc0 { } 3. public class Test { 4. public static void main(String args[]) { 5. try { 6. throw new Exc1(); 7. } catch (Exc0 e0) { 8. System.out.println(“Ex0 caught”); 9. } catch (Exception e) { 10. System.out.println(“exception caught”); 11. } 12. } 13. } What is the result?()
第21题:
private class My Class extends Object
class My Class extends Object
public class My Class
public class My Class extends Object
第22题:
Alpha a = x;
Foo f= (Delta)x;
Foo f= (Alpha)x;
Beta b = (Beta)(Alpha)x;
第23题:
StackOverflowError
NullPointerException
NumberFormatException
IllegalArgumentException
ExceptionlnlnitializerError
第24题:
class A { public A(int x) {} }
class A {} class B extends A { B() {} }
class A { A() {} } class B { public B() {} }
class Z { public Z(int) {} } class A extends Z {}