单选题class Guy{String greet(){return “hi“}} class Cowboy extends Guy {String greet(){return“howdy”}} class Surfer extends Guy {String greet(){return“dudel”}} class Greetings{ public static void main (string[]args){ Guy[] guy= {new Guy(),new Cowboy(),new Surfer()}; for(Guy 0: guys) System.out.print(g.green()); } } 结果为:A运行时异常被输出B第7行出现一个错误,编译失败C第8行出现一个错误,编译失败Dhi hi hiEhi hawdy doude
单选题
class Guy{String greet(){return “hi“}} class Cowboy extends Guy {String greet(){return“howdy”}} class Surfer extends Guy {String greet(){return“dudel”}} class Greetings{ public static void main (string[]args){ Guy[] guy= {new Guy(),new Cowboy(),new Surfer()}; for(Guy 0: guys) System.out.print(g.green()); } } 结果为:
A
运行时异常被输出
B
第7行出现一个错误,编译失败
C
第8行出现一个错误,编译失败
D
hi hi hi
E
hi hawdy doude
参考解析
解析:
暂无解析
相关考题:
Which statements concerning the following code are true?() class a { public a() {} public a(int i) { this(); } } class b extends a { public boolean b(String msg) { return false; } } class c extends b { private c() { super(); } public c(String msg) { this(); } public c(int i) {} } A、The code will fail to compile.B、The constructor in a that takes an int as an argument will never be called as a result of constructing an object of class b or c.C、Class c has three constructors.D、Objects of class b cannot be constructed.E、At most one of the constructors of each class is called as a result of constructing an object of class c.
class Guy { String greet() { return "hi "; } } class Cowboy extends Guy { String greet() { return "howdy "; } } class Wrangler extends Cowboy { String greet() { return "ouch! "; } } class Greetings2 { public static void main(String [] args) { Guy g = new Wrangler(); Guy g2 = new Cowboy(); Wrangler w2 = new Wrangler(); System.out.print(g.greet()+g2.greet()+w2.greet()); } } 结果是什么?() A、hi hi ouch!B、hi howdy ouch!C、ouch! howdy ouch!D、编译失败
class Guy{String greet(){return “hi“}} class Cowboy extends Guy {String greet(){return“howdy”}} class Surfer extends Guy {String greet(){return“dudel”}} class Greetings{ public static void main (string[]args){ Guy[] guy= {new Guy(),new Cowboy(),new Surfer()}; for(Guy 0: guys) System.out.print(g.green()); } } 结果为: A、运行时异常被输出B、第7行出现一个错误,编译失败C、第8行出现一个错误,编译失败D、hi hi hiE、hi hawdy doude
class Mineral { static String shiny() { return "1"; } } class Granite extends Mineral { public static void main(String [] args) { String s = shiny() + getShiny(); s = s + super.shiny(); System.out.println(s); } static String getShiny() { return shiny(); } } 结果为:() A、3B、12C、111D、编译失败
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?()A、 Yen returns correct values.B、 Euro returns correct values.C、 An exception is thrown at runtime.D、 Yen and Euro both return correct values.E、 Compilation fails because of an error at line 25.F、 Compilation fails because of an error at line 30.
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”)后程序的输出是哪项?() A、 smithB、 nullC、 编译错误D、 name
public class X { public X aMethod() { return this;} } public class Y extends X { } Which two methods can be added to the definition of class Y?()A、 public void aMethod() {}B、 private void aMethod() {}C、 public void aMethod(String s) {}D、 private Y aMethod() { return null; }E、 public X aMethod() { return new Y(); }
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.
现有: class Guy {String greet() {return "hi"; } } class Cowboy extends Guy ( String greet() ( return "howdy ¨; ) ) class Surfer extends Guy (String greet() (return "dude! ";)) class Greetings { public static void main (String [] args) { Guy [] guys = ( new Guy(), new Cowboy(), new Surfer() ); for (Guy g: guys) System.out.print (g.greet()}; } } 结果为:() A、 hi howdy dude!B、运行时异常被抛出。C、第7行出现一个错误,编译失败。D、第8行出现一个错误,编译失败。
Which methods from the String and StringBuffer classes modify the object on which they are called?() A、The charAt() method of the String class.B、The toUpperCase() method of the String class.C、The replace() method of the String class.D、The reverse() method of the StringBuffer class.E、The length() method of the StringBuffer class.
现有: 1. abstract class Color { 2.protected abstract String getRGB(); 3. } 4. 5. public class Blue extends Color { 6. //insert code here 7. } 和四个声明: public String getRGB() { return "blue"; } String getRGB() { return "blue"; ) private String getRGB() { return "blue"; } protected String getRGB() { return "blue"; ) 分别插入到第6行,有几个可以通过编译?() A、 0B、 1C、 2D、 3
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?() A、 The code will compile without changes.B、 The code will compile if public Tree() { Plant(); } is added to the Tree class.C、 The code will compile if public Plant() { Tree(); } is added to the Plant class.D、 The code will compile if public Plant() { this(”fern”); } is added to the Plant class.E、 The code will compile if public Plant() { Plant(”fern”); } is added to the Plant class.
interface Beta {} class Alpha implements Beta { String testIt() { return “Tested”; } } public class Main1 { static Beta getIt() { return new Alpha(); } public static void main( String[] args ) { Beta b = getIt(); System.out.println( b.testIt() ); } } What is the result?() A、 TestedB、 Compilation fails.C、 The code runs with no output.D、 An exception is thrown at runtime.
class Parser extends Utils { public static void main(String [] args) { System.out.print(new Parser().getInt("42")); } int getInt(String arg) { return Integer.parseInt(arg); } } class Utils { int getInt(String arg) throws Exception { return 42; } } 结果为:() A、42B、编译失败C、无输出结果D、运行时异常被抛出
You work as the application developer at Hi-Tech.com. You create a new custom dictionary named MyDictionary. Choose the code segment which will ensure that MyDictionary is type safe?()A、 Class MyDictionary Implements Dictionary (Of String,String)B、 Class MyDictionary Inherits HashTableC、 Class MyDictionary Implements IDictionaryD、 Class MyDictionary End Class Dim t as New Dictionary (Of String, String) Dim dict As MyDIctionary= CType (t,MyDictionary)
单选题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 statements concerning the following code are true?() class a { public a() {} public a(int i) { this(); } } class b extends a { public boolean b(String msg) { return false; } } class c extends b { private c() { super(); } public c(String msg) { this(); } public c(int i) {} }AThe code will fail to compile.BThe constructor in a that takes an int as an argument will never be called as a result of constructing an object of class b or c.CClass c has three constructors.DObjects of class b cannot be constructed.EAt most one of the constructors of each class is called as a result of constructing an object of class c.
单选题现有: 1. abstract class Color { 2.protected abstract String getRGB(); 3. } 4. 5. public class Blue extends Color { 6. //insert code here 7. } 和四个声明: public String getRGB() { return "blue"; } String getRGB() { return "blue"; ) private String getRGB() { return "blue"; } protected String getRGB() { return "blue"; ) 分别插入到第6行,有几个可以通过编译?()A 0B 1C 2D 3
单选题You work as the application developer at Hi-Tech.com. You create a new custom dictionary named MyDictionary. Choose the code segment which will ensure that MyDictionary is type safe?()A Class MyDictionary Implements Dictionary (Of String,String)B Class MyDictionary Inherits HashTableC Class MyDictionary Implements IDictionaryD Class MyDictionary End Class Dim t as New Dictionary (Of String, String) Dim dict As MyDIctionary= CType (t,MyDictionary)
单选题class Parser extends Utils { public static void main(String [] args) { System.out.print(new Parser().getInt("42")); } int getInt(String arg) { return Integer.parseInt(arg); } } class Utils { int getInt(String arg) throws Exception { return 42; } } 结果为:()A42B编译失败C无输出结果D运行时异常被抛出
多选题public class X { public X aMethod() { return this;} } public class Y extends X { } Which two methods can be added to the definition of class Y?()Apublic void aMethod() {}Bprivate void aMethod() {}Cpublic void aMethod(String s) {}Dprivate Y aMethod() { return null; }Epublic X aMethod() { return new Y(); }
单选题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?()A The code will compile without changes.B The code will compile if public Tree() { Plant(); } is added to the Tree class.C The code will compile if public Plant() { Tree(); } is added to the Plant class.D The code will compile if public Plant() { this(”fern”); } is added to the Plant class.E The code will compile if public Plant() { Plant(”fern”); } is added to the Plant class.
单选题现有: class Guy { String greet() { return "hi"; } } class Cowboy extends Guy { String greet() { return. "howdy";}} class Wrangler extends Cowboy { String greet() { return "orch!"; } } class Greetings2 { public static void main (String [] args) { Guy g=new Wrangler(); Guy g2=new Cowboy(); Wrangler w2=new Wrangler(); System. out .print (g.greet()+g2.greet()+w2 .greet()); } } 结果是什么?()A hi hi ouch!B ouch! howdy ouch!C hi howdy ouch!D编译失败E运行的咐候有异常抛出
单选题现有: class Guy {String greet() {return "hi"; } } class Cowboy extends Guy ( String greet() ( return "howdy ¨; ) ) class Surfer extends Guy (String greet() (return "dude! ";)) class Greetings { public static void main (String [] args) { Guy [] guys = ( new Guy(), new Cowboy(), new Surfer() ); for (Guy g: guys) System.out.print (g.greet()}; } } 结果为:()A hi howdy dude!B运行时异常被抛出。C第7行出现一个错误,编译失败。D第8行出现一个错误,编译失败。
单选题class Guy { String greet() { return "hi "; } } class Cowboy extends Guy { String greet() { return "howdy "; } } class Wrangler extends Cowboy { String greet() { return "ouch! "; } } class Greetings2 { public static void main(String [] args) { Guy g = new Wrangler(); Guy g2 = new Cowboy(); Wrangler w2 = new Wrangler(); System.out.print(g.greet()+g2.greet()+w2.greet()); } } 结果是什么?()Ahi hi ouch!Bhi howdy ouch!Couch! howdy ouch!D编译失败
多选题public class Car { private int wheelCount; private String vin; public Car(String vin) { this.vin = vin; this.wheelCount = 4; } public String drive() { return “zoom-zoom”; } public String getInfo() { return “VIN: “+ vin + “wheels: “+ wheelCount; } } And: public class MeGo extends Car { public MeGo(String vin) { this.wheelCount = 3; } } What two must the programmer do to correct the compilation errors?()Ainsert a call to this() in the Car constructorBinsert a call to this() in the MeGo constructorCinsert a call to super() in the MeGo constructorDinsert a call to super(vin) in the MeGo constructorEchange the wheelCount variable in Car to protectedFchange line 3 in the MeGo class to super.wheelCount = 3;
单选题class Mineral { static String shiny() { return "1"; } } class Granite extends Mineral { public static void main(String [] args) { String s = shiny() + getShiny(); s = s + super.shiny(); System.out.println(s); } static String getShiny() { return shiny(); } } 结果为:()A3B12C111D编译失败