classCatextendsAnimal{}对于下述代码说法正确的是()
第1题:
A.Animalanimal=newCat()
B.Catcat=(Cat)newDog()
C.Catcat=(Cat)newAnimal()
D.Animalanimal=newDog()
第2题:
classAnimal{AnimalgetOne(){returnnewAnimal();}}classDogextendsAnimal{//insertcodehere}classAnimalTest{publicstaticvoidmain(String[]args){Animal[]animal={newAnimal(),newDog()};for(Animala:animal){Animalx=a.getOne();}}}和代码:3a.DoggetOne(){returnnewDog();}3b.AnimalgetOne(){returnnewDog();}第3行中插入的哪项编译且运行无异常?
A.3a行或3b行
B.既非3a,也非3b
C.3a行
D.3b行
第3题:
A.Objecto=newDog();
B.Animala=newDog();
C.Objectd=(Dog)newAnimal()
D.Animala=(Animal)newDog();
第4题:
假定在窗体(名称为Form1)的代码窗口中定义如下记录类型:
Private Type animal
AnimalName As String*20
AColor As String*10
End Type
在窗体上画一个名称为Command1的命令按钮,然后编写如下事件过程:
Private Sub Command1_Click()
Dim rec As animal
Open "c:\vbTest.dat" For Random As #1 Len = Len(rec)
rec.animalName = "Cat"
rec.aColor = "White"
Put #1, , rec
Close #1
End Sub
则以下叙述中正确的是( )。
A.记录类型animal不能在Form1中定义,必须在标准模块中定义
B.如果文件c:\vbTest.dat不存在,则Open命令执行失败
C.由于Put命令中没有指明记录号,因此每次都把记录写到文件的末尾
D.语句“Put #1, , rec”将animal类型的两个数据元素写到文件中
第5题:
Animal is a super-ordinate term, while cow, horse, pig, dog, cat, etc. are().
hyponyms
略
第6题:
10. interface Jumper { public void jump(); } ...... 20. class Animal {} ...... 30. class Dog extends Animal { 31. Tail tail; 32. } ...... 40. class Beagle extends Dog implements Jumper { 41. public void jump() { } 42. } ....... 50. class Cat implements Jumper { 51. public void jump() { } 52. } Which three are true?()
第7题:
interface Animal { void soundOff(); } class Elephant implements Animal { public void soundOff() { System.out.println(“Trumpet”); } } class Lion implements Animal { public void soundOff() { System.out.println(“Roar”); } } class Alpha1 { static Animal get( String choice ) { if ( choice.equalsIgnoreCase( “meat eater” )) { return new Lion(); } else { return new Elephant(); } } } Which compiles?()
第8题:
11. class Animal { public String noise() { return “peep”; } } 12. class Dog extends Animal { 13. public String noise() { return “bark”; } 14. } 15. class Cat extends Animal { 16. public String noise() { return “meow”; } 17. } ..... 30. Animal animal = new Dog(); 31. Cat cat = (Cat)animal; 32. System.out.printIn(cat.noise()); What is the result?()
第9题:
1. class Animal { Animal getOne() { return new Animal(); } } 2. class Dog extends Animal { 3. // insert code here 4. } 5. 6. class AnimalTest { 7. public static void main(String [] args) { 8. Animal [] animal = { new Animal(), new Dog() } ; 9. for( Animal a : animal) { 10. Animal x = a.getOne(); 11. } 12. } 13. } 和代码: 3a. Dog getOne() { return new Dog(); } 3b. Animal getOne() { return new Dog(); } 第 3 行中插入的哪项将编译且运行无异常?()
第10题:
Cat is-a Jumper
Cat is-a Animal
Dog is-a Jumper
Dog is-a Animal
Beagle has-a Jumper
Cat has-a Animal
Beagle has-a Tail
第11题:
第12题:
Cat is-a Animal
Cat is-a Jumper
Dog is-a Animal
Dog is-a Jumper
Cat has-a Animal
Beagle has-a Tail
Beagle has-a Jumper
第13题:
以下关于C#代码的说法正确的是()publicabstractclassAnimal{publicabstractvoidEat();publicvoidSleep(){}}
A、代码编译错误,因为类中方法没有实现
B、代码编译错误,因为类中存在非抽象方法
C、该段代码正确
D、通过代码”Animalan=newAnimal();”可以创建一个Animal对象
第14题:
11.classAnimal{publicStringnoise(){returnpeep”;}}12.classDogextendsAnimal{13.publicStringnoise(){returnbark”;}14.}15.classCatextendsAnimal{16.publicStringnoise(){returnmeow”;}17.}.....30.Animalanimal=newDog();31.Catcat=(Cat)animal;32.System.out.printIn(cat.noise());Whatistheresult?()
A.peep
B.bark
C.meow
D.Compilationfails.
E.Anexceptionisthrownatruntime.
第15题:
下列程序片段中,能通过编译的是( )。
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{};}
第16题:
第17题:
在Java中,类Animal中的方法printA()定义如下: public void printA() { Int a=10; Int result =10%3; System.out.println(result); } 在类Dog中方法printA()定义如下: public void printA() { Int a=10; System.out.println(a/3); } Dog类的定义如下: Class Dog extends Animal{…}. Animal animal=new Dog(); animal.printA(); 以上语句输出结果为()。
第18题:
class Animal{ Animal getOne(){return new Animal();}} class Dog extends Animal{ //insert code here } class AnimalTest{ public static void main(String[] args){ Animal[] animal={ new Animal(), new Dog()}; for(Animal a:animal){ Animal x= a.getOne(); } } } 和代码: 3a.Dog getOne() { return new Dog();} 3b.Animal getOne() { return new Dog();} 第3行中插入的哪项编译且运行无异常?
第19题:
publicabstractclassAnimal{publicabstractvoidEat();publicvoidSleep(){}}以下关于C#代码地描述正确的是()。
第20题:
现有: interface Animal { void eat () ; } //insert code here public class HouseCat extends Feline { public void eat() { } } 和五个申明 abstract class Feline implements Animal { } abstract class Feline implements Animal { void eat () ; } abstract class Feline implements Animal { public void eat();} abstract class Feline implements Animal { public void eat() {} } abstract class Feline implements Animal { abstract public void eat();} 结果为:()
第21题:
现有: 1. interface Animal { 2. void eat(); 3. } 4. 5. // insert code here 6. 7. public class HouseCat extends Feline { 8. public void eat() { } 9. } 和五个声明: abstract class Feline implements Animal { } abstract class Feline implements Animal { void eat(); } abstract class Feline implements Animal { public void eat(); } abstract class Feline implements Animal { public void eat() { } } abstract class Feline implements Animal { abstract public void eat(); } 分别插入到第5行,有几个可以通过编译?()
第22题:
该段代码正确
代码错误〃因为类中存在非抽象方法
代码错误〃因为类中方法没有实现
通过代码Animalan=newAnimal;可以创建一个Animal对象
第23题:
peep
bark
meow
Compilation fails.
An exception is thrown at runtime.