public class Test { public enum Dogs {collie, harrier, shepherd}; public static void main(String [] args) { Dogs myDog = Dogs.shepherd; switch (myDog) { case collie: System.out.print(”collie “); case default: System.out.print(”retriever “); case harrier: System.out.print(”harrier “); } } } What is the result?()
第1题:
下列程序片段中,能通过编译的是( )。
A.public abstract class Animal{public void speak( );}
B.public abstract class Animal{public void speak( ){};}
C.public class Animal{pubilc abstract void speak( );}
D.public abstract class Animal{pubile abstract void speak( ){};}
第2题:
下列程序片段中,能通过编译的是( )。
A.public abstract class Animal{ public void speak;}
B.public abstract class Animal{ public void speak{);}
C.public class Animal{ pubilc abstract void speak;}
D.public abstract class Animal{ pubile abstract void speak{};}
第3题:
In which two cases does the compiler supply a default constructor for class A?()
第4题:
interface Data { public void load(); } abstract class Info { public abstract void load(); } Which class correctly uses the Data interface and Info class?()
第5题:
下面哪一个是正确的类的声明?()
第6题:
package geometry; public class Hypotenuse { public InnerTriangle it = new InnerTriangle(); class InnerTriangle { public int base; public int height; } } Which is true about the class of an object that can reference the variable base? ()
第7题:
Which two demonstrate an “is a” relationship?()
第8题:
What produces a compiler error?()
第9题:
public class Employee extends Info implements Data { public void load() { /*do something*/ } }
public class Employee implements Info extends Data { public void load() { /*do something*/ } }
public class Employee extends Info implements Data { public void load() { /*do something */ } public void Info.load() { /*do something*/ } }
public class Employee implements Info extends Data { public void Data.load() { /*dsomething */ } public void load() { /*do something */ } }
public class Employee implements Info extends Data { public void load() { /*do something */ } public void Info.load(){ /*do something*/ } }
public class Employee extends Info implements Data{ public void Data.load() { /*do something*/ } public void Info.load() { /*do something*/ } }
第10题:
It can be any class.
No class has access to base.
The class must belong to the geometry package.
The class must be a subclass of the class Hypotenuse.
第11题:
public class Thing { }
public class Thing { public Thing() {} }
public class Thing { public Thing(void) {} }
public class Thing { public Thing(String s) {} }
public class Thing { public void Thing() {} public Thing(String s) {} }
第12题:
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.
第13题:
下面程序输出的结果为 #include"iostream.h” class A { public: A(){cout<<"CLASSA"<<endl;} ~A() {} }; class B:public A { public: B(){cout<<"CLASS B"<<endl;} ~B(){} }; void main() { A*p; p=new B;
A.CLASS A CLASS B CLASS B CLASS B
B.CLASS A CLASS B CLASS A CLASS B
C.CLASS A CLASS B CLASS B
D.CLASS A CLASS B
第14题:
public class SomeException { } Class a: public class a { public void doSomething() { } } Class b: public class b extends a { public void doSomething() throws SomeException { } } Which is true about the two classes?()
第15题:
Which three demonstrate an “is a” relationship?()
第16题:
Which two allow the class Thing to be instantiated using new Thing()?
第17题:
在C#程序中,如果类B要继承类A,类B正确的定义为()。
第18题:
Which the two demonstrate an “is a” relationship?()
第19题:
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?()
第20题:
public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape class correctly?()
第21题:
public class X { } public class Y extends X { }
public interface Shape { } public interface Rectangle extends Shape{ }
public interface Color { } public class Shape { private Color color; }
public interface Species { } public class Animal { private Species species; }
public class Person { } public class Employee { public Employee(Person person) { }
interface Component { } class Container implements Component { private Component[] children; }
第22题:
Compilation of both classes will fail.
Compilation of both classes will succeed.
Compilation of class a will fail. Compilation of class b will succeed.
Compilation of class a will fail. Compilation of class a will succeed.
第23题:
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; )
第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 {}