网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
单选题
class Dog { } class Harrier extends Dog { } class DogTest { public static void main(String [] args) { Dog d1 = new Dog(); Harrier h1 = new Harrier(); Dog d2 = h1; Harrier h2 = (Harrier) d2; Harrier h3 = d2; } } 下面哪一项是正确的?()
A
编译失败
B
2个Dog对象被创建
C
2个Harrier对象被创建
D
3个Harrier对象被创建
参考答案
参考解析
解析:
暂无解析
更多 “单选题class Dog { } class Harrier extends Dog { } class DogTest { public static void main(String [] args) { Dog d1 = new Dog(); Harrier h1 = new Harrier(); Dog d2 = h1; Harrier h2 = (Harrier) d2; Harrier h3 = d2; } } 下面哪一项是正确的?()A 编译失败B 2个Dog对象被创建C 2个Harrier对象被创建D 3个Harrier对象被创建” 相关考题
考题
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(String name){ System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?() A、 23B、 13C、 123D、 321
考题
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?()A、 Cat is-a AnimalB、 Cat is-a JumperC、 Dog is-a AnimalD、 Dog is-a JumperE、 Cat has-a AnimalF、 Beagle has-a TailG、 Beagle has-a Jumper
考题
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京巴
考题
class Dog { } class Harrier extends Dog { } class DogTest { public static void main(String [] args) { Dog d1 = new Dog(); Harrier h1 = new Harrier(); Dog d2 = h1; Harrier h2 = (Harrier) d2; Harrier h3 = d2; } } 下面哪一项是正确的?() A、编译失败B、2个Dog对象被创建C、2个Harrier对象被创建D、3个Harrier对象被创建
考题
现有: class Dog{ } class Harrier extends Dog { } class DogTest{ public static void main (String [] args) { Dog dl=new Dog(); Harrier hl=new Harrier(); Dog d2=hl; Harrier h2= (Harrier) d2; Harrier h3=d2; } } 下面哪一项是正确的?() A、2个Dog对象被创建B、2个Harrier对象被创建C、3个Harrier对象被创建D、编译失败
考题
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(String name){ //这里隐藏了一句代码:super.pet(); System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?() A、 23B、 1 3C、 123D、 321
考题
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?() A、 peepB、 barkC、 meowD、 Compilation fails.E、 An exception is thrown at runtime.
考题
Which Man class properly represents the relationship "Man has a best friend who is a Dog"?()A、class Man extends Dog{}B、class Man implements Dog{}C、class Man{private BestFriend dog;}D、class Man{private Dog bestFriend;}E、class Man{private Dog;}F、class Man{private BestFriend;}
考题
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.pet(); this(); System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?() A、 143B、 423C、 243D、 1134
考题
What produces a compiler error?() A、 class A { public A(int x) {} }B、 class A {} class B extends A { B() {} }C、 class A { A() {} } class B { public B() {} }D、 class Z { public Z(int) {} } class A extends Z {}
考题
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){ this(); System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?() A、 143B、 423C、 243D、 1134
考题
Which Man clsss properly represents the relationship "Man has a best friend who is a Dog"?()A、class Man extends Dog { }B、class Man implements Dog { }C、class Man { private BestFriend dog; }D、class Man { private Dog bestFriend; }E、class Man { private Dog; }F、class Man { private BestFriend; }
考题
Which Man class properly represents the relationship "Man has a best friend who is a Dog"?()A、class Man extends Dog { }B、class Man implements Dog { }C、class Man { private BestFriend dog; }D、class Man { private Dog bestFriend; }E、class Man { private DogbestFriend; }F、class Man { private BestFrienddog; }
考题
单选题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
考题
多选题Given: 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?()ACat is-a JumperBCat is-a AnimalCDog is-a JumperDDog is-a AnimalEBeagle has-a JumperFCat has-a AnimalGBeagle has-a Tail
考题
单选题现有: class Dog{ } class Harrier extends Dog { } class DogTest{ public static void main (String [] args) { Dog dl=new Dog(); Harrier hl=new Harrier(); Dog d2=hl; Harrier h2= (Harrier) d2; Harrier h3=d2; } } 下面哪一项是正确的?()A
2个Dog对象被创建B
2个Harrier对象被创建C
3个Harrier对象被创建D
编译失败
考题
单选题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?()A
peepB
barkC
meowD
Compilation fails.E
An exception is thrown at runtime.
考题
单选题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(String name){ System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?()A
23B
13C
123D
321
考题
单选题public class Pet{ public void speak(){ System.out.print(“ Pet ”); } } public class Cat extends Pet{ public void speak(){ System.out.print(“ Cat ”); } } public class Dog extends Pet{ public void speak(){ System.out.print(“ Dog ”); } } 执行代码 Pet[] p = {new Cat(),new Dog(),new Pet()}; for(int i=0;i〈p.length;i++) p[i].speak(); 后输出的内容是哪项?()A
Pet Pet PetB
Cat Cat CatC
Cat Dog PetD
Cat Dog Dog
考题
单选题Which Man class properly represents the relationship “Man has a best friend who is a Dog”?()A
class Man extends Dog { }B
class Man implements Dog { }C
class Man { private BestFriend dog; }D
class Man { private Dog bestFriend; }E
class Man { private Dog }F
class Man { private BestFriend }
考题
单选题Which Man class properly represents the relationship "Man has a best friend who is a Dog"?()A
class Man extends Dog { }B
class Man implements Dog { }C
class Man { private BestFriend dog; }D
class Man { private Dog bestFriend; }E
class Man { private DogbestFriend; }F
class Man { private BestFrienddog; }
考题
单选题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(String name){ //这里隐藏了一句代码:super.pet(); System.out.print(3); } } 执行new Dog(“棕熊”);后程序输出是哪项?()A
23B
1 3C
123D
321
考题
单选题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京巴
考题
单选题Which Man class properly represents the relationship "Man has a best friend who is a Dog"?()A
class Man extends Dog{}B
class Man implements Dog{}C
class Man{private BestFriend dog;}D
class Man{private Dog bestFriend;}E
class Man{private Dog;}F
class Man{private BestFriend;}
考题
多选题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?()ACat is-a AnimalBCat is-a JumperCDog is-a AnimalDDog is-a JumperECat has-a AnimalFBeagle has-a TailGBeagle has-a Jumper
考题
单选题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 行中插入的哪项将编译且运行无异常?()A
3a行B
3b行C
3a行或3b行D
既非3a,也非3b
考题
单选题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行中插入的哪项编译且运行无异常?A
3a行或3b行B
既非3a,也非3bC
3a行D
3b行
热门标签
最新试卷