多项选择题
GivenafileGrizzlyBear.java:
1.package animals.mammals;
2.
3.public class GrizzlyBear extends Bear{
4.voidhunt(){
5.Salmons=findSalmon();
6.s.consume();
7.}
8.}
and another file,Salmon.java:
1.packageanimals.fish;
2.
3.public class Salmon extends Fish{
4.voidconsume(){/*dostuff*/}
5.}
Assume both classes are defined in the correct directories for theft packages,and that the Mammal class correctly defines the findSalmon()method.Which two changes allow this code to compile correctly?()
A.add public to the start of line 4 in Salmon.java
B.add public to the start of line 4 in GrizzlyBear.java
C.add import animals.mammals.*;at line 2 in Salmon.java
D.add import animals.fish.*at line 2 in GrizzlyBear.java
E.add import animals.fish.Salmon.*;at line 2 in GrizzlyBear.java
F.add import animals.mammals.GrizzlyBear.*;at line 2 in Salmon.java
相关考题
-
单项选择题
1.public classA{ 2.public String doit(intx,inty){ 3.return"a"; 4.} 5. 6.public String doit(int...vals){ 7.return"b"; 8.} 9.} And: 25.A a=new A(); 26.System.out.println(a.doit(4,5)); What is the result?()
A.Line 26 prints "a" to System.out.
B.Line 26 prints "b" to System.out.
C.An exception is thrown at line 26 at runtime.
D.Compilation of class A will fail due to an error in line 6. -
单项选择题
A programmer needs to create a logging method that can accept an arbitrary number of arguments.Forexample,it may be called in these ways: logIt("log message 1"); logIt("log message 2”,”log message 3"); logIt("log message 4","log message 5","log message 6"); Which declaration satisfies this requirement()?
A.public void logIt(String*msgs)
B.public void logIt(String[]msgs)
C.public void logIt(String...msgs)
D.public voidl ogIt(Stringmsg1,Stringmsg2,Stringmsg3) -
多项选择题
10.publicclassBar{ 11.staticvoidfoo(int...x){ 12.//insertcodehere 13.} 14.} Which two code fragments,inserted independently at line1 2,will allow the class to compile()
A.foreach(x)System.out.println(z);
B.for(intz:x)System.out.println(z);
C.while(x.hasNext())System.out.println(x.next());
D.for(inti=0;i
