单选题Given a class Repetition: 1.package utils; 2. 3.public class Repetition{ 4.public static String twice(Strings){returns+s;} 5.} and given another class Demo: 1.//insert code here2. 3.public class Demo{ 4.public static void main(String[]args){ 5.System.out.println(twice("pizza")); 6.} 7.} Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()Aimport utils.*;Bstatic import utils.*;Cimportutils.Repetition.*;Dstatic importutils.Repetition.*;Eimport utils.Repetition.twice();Fimport static utils.Repetition.twice;Gstatic import utils.Repetition.twice;
单选题
Given a class Repetition: 1.package utils; 2. 3.public class Repetition{ 4.public static String twice(Strings){returns+s;} 5.} and given another class Demo: 1.//insert code here2. 3.public class Demo{ 4.public static void main(String[]args){ 5.System.out.println(twice("pizza")); 6.} 7.} Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()
A
import utils.*;
B
static import utils.*;
C
importutils.Repetition.*;
D
static importutils.Repetition.*;
E
import utils.Repetition.twice();
F
import static utils.Repetition.twice;
G
static import utils.Repetition.twice;
参考解析
解析:
暂无解析
相关考题:
public class Test{2.int x=12;3.public void method(intx){4.x+=x;5.System.out.println(x);6.}7.}Given:34.Test t=new Test();35.t.method(5);What is the output from line 5 of the Test class?() A.5B.10C.12D.17E.24
Given:What can directly access and change the value of the variable name?() A. any classB. only the Target classC. any class in the test packageD. any class that extends Target
Given:10. interface Data { public void load(); }11. abstract class Info { public abstract void load(); }Which class correctly uses the Data interface and Info class?()() A.B.C.D.E.F.
Given:Which two, inserted at line 11, will allow the code to compile?() A.public class MinMax? {B.public class MinMax? extends Number {C.public class MinMaxN extends Object {D.public class MinMaxN extends Number {E.public class MinMax? extends Object {F.public class MinMaxN extends Integer {
Given:Which statement is true about the class of an object that can reference the variable base? () A.It can be any class.B.No class has access to base.C.The class must belong to the geometry package.D.The class must be a subclass of the class Hypotenuse.
Given a class Repetition:Which code should be inserted at line 1 of Demo.java to compile and run Demo to print pizzapizza?() A.import utils.*;B.static import utils.*;C.import utils.Repetition.*;D.static import utils.Repetition.*;E.import utils.Repetition.twice();F.import static utils.Repetition.twice;G.static import utils.Repetition.twice;
Which two statements are true about the hashCode method?()A、 The hashCode method for a given class can be used to test for object equality and object inequality for that class.B、 The hashCode method is used by the java.util.SortedSet collection class to order theelements within that set.C、 The hashCode method for a given class can be used to test for object inequality, but NOT object equality, for that class.D、 The only important characteristic of the values returned by a hashCode method is that the distribution of values must follow a Gaussian distribution.E、 The hashCode method is used by the java.util.HashSet collection class to group the elements within that set into hash buckets for swift retrieval.
1. public class a { 2. public void method1() { 3. try { 4. B b=new b(); 5. b.method2(); 6. // more code here 7. } catch (TestException te) { 8. throw new RuntimeException(te); 9. } 10. } 11. } 1. public class b { 2. public void method2() throws TestException { 3. // more code here 4. } 5. } 1. public class TestException extends Exception { 2. } Given: 31. public void method() { 32. A a=new a(); 33. a.method1(); 34. } Which is true if a TestException is thrown on line 3 of class b?()A、 Line 33 must be called within a try block.B、 The exception thrown by method1 in class a is not required to be caught.C、 The method declared on line 31 must be declared to throw a RuntimeException.D、 On line 5 of class a, the call to method2 of class b does not need to be placed in a try/catch block.
Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true?()A、The class implements java.lang.Comparable.B、The class implements java.util.Comparator.C、The interface used to implement sorting allows this class to define only one sort sequence.D、The interface used to implement sorting allows this class to define many different sort sequences.
定义类: package utils; public class Rep{ public static String twice (String s){return s+s ;} } 再定义另一个类Demo: //insert code here public class Demo{ public static void main (String[] args){ System. out .println( twice( "Hello")); } } 在第一行插入哪项代码,可以使程序正常编译和执行?() A、import utils.*;B、 import utils.Rep.*;C、 import static utils.Rep.twice;D、 static import utils.Rep.twice;
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、运行时异常被抛出
Given the following directory structure: bigProject |--source ||--Utils.java| |--classes |-- And the following command line invocation: javac -d classes source/Utils.java Assume the current directory is bigProject,what is the result?()A、If the compile is successful, Utils.class is added to the source directory.B、The compiler returns an invalid flag error.C、If the compile is successful, Utils.class is added to the classes directory.D、If the compile is successful, Utils.class is added to the bigProject directory.
单选题Given: 1.package test; 2. 3.class Target { 4.public String name = "hello";5.} What can directly access and change the value of the variable name?()Aany classBonly the Target classCany class in the test packageDany class that extends Target
单选题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运行时异常被抛出
单选题Given classes defined in two different files: 1.package util; 2.public class BitUtils{ 3.private static void process(byte[]b){} 4.} 1.package app; 2.public class SomeApp{ 3.public static void main(String[]args){ 4.byte[]bytes=newbyte[256]; 5.//insert code here 6.} 7.} What is required at line 5 in class SomeApp to use the process method of BitUtils?()Aprocess(bytes);BBitUtils.process(bytes);Capp.BitUtils.process(bytes);Dutil.BitUtils.process(bytes);Eimportutil.BitUtils.*;process(bytes);FSomeApp cannot use the process method in BitUtils.
单选题Given the following directory structure: bigProject |--source ||--Utils.java| |--classes |-- And the following command line invocation: javac -d classes source/Utils.java Assume the current directory is bigProject,what is the result?()AIf the compile is successful, Utils.class is added to the source directory.BThe compiler returns an invalid flag error.CIf the compile is successful, Utils.class is added to the classes directory.DIf the compile is successful, Utils.class is added to the bigProject directory.
单选题Given: 1.package test; 2. 3.class Target { 4.public String name = "hello";5.} What can directly access and change the value of the variable name?()Aany classBonly the Target classCany class in the test packageDany class that extends Target
多选题Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true?()AThe class implements java.lang.Comparable.BThe class implements java.util.Comparator.CThe interface used to implement sorting allows this class to define only one sort sequence.DThe interface used to implement sorting allows this class to define many different sort sequences.
单选题1. public class a { 2. public void method1() { 3. try { 4. B b=new b(); 5. b.method2(); 6. // more code here 7. } catch (TestException te) { 8. throw new RuntimeException(te); 9. } 10. } 11. } 1. public class b { 2. public void method2() throws TestException { 3. // more code here 4. } 5. } 1. public class TestException extends Exception { 2. } Given: 31. public void method() { 32. A a=new a(); 33. a.method1(); 34. } Which is true if a TestException is thrown on line 3 of class b?()A Line 33 must be called within a try block.B The exception thrown by method1 in class a is not required to be caught.C The method declared on line 31 must be declared to throw a RuntimeException.D On line 5 of class a, the call to method2 of class b does not need to be placed in a try/catch block.
单选题定义类: package utils; public class Rep{ public static String twice (String s){return s+s ;} } 再定义另一个类Demo: //insert code here public class Demo{ public static void main (String[] args){ System. out .println( twice( "Hello")); } } 在第一行插入哪项代码,可以使程序正常编译和执行?()Aimport utils.*;B import utils.Rep.*;C import static utils.Rep.twice;D static import utils.Rep.twice;
多选题1. public class A { 2. public void method1() { 3. B b=new B(); 4. b.method2(); 5. // more code here 6. } 7. } 1. public class B { 2. public void method2() { 3.C c=new C(); 4. c.method3(); 5. // more code here 6. } 7. } 1. public class C { 2. public void method3() { 3. // more code here 4. } 5. } Given: 25. try { 26. A a=new A(); 27. a.method1(); 28. } catch (Exception e) { 29. System.out.print(”an error occurred”); 30. } Which two are true if a NullPointerException is thrown on line 3 of class C?()AThe application will crash.BThe code on line 29 will be executed.CThe code on line 5 of class A will execute.DThe code on line 5 of class B will execute.EThe exception will be propagated back to line 27.
单选题Given a class Repetition: 1.package utils; 2. 3.public class Repetition{ 4.public static String twice(Strings){returns+s;} 5.} and given another class Demo: 1.//insert code here2. 3.public class Demo{ 4.public static void main(String[]args){ 5.System.out.println(twice("pizza")); 6.} 7.} Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()Aimport utils.*;Bstatic import utils.*;Cimportutils.Repetition.*;Dstatic importutils.Repetition.*;Eimport utils.Repetition.twice();Fimport static utils.Repetition.twice;Gstatic import utils.Repetition.twice;
单选题1.public class Test{ 2.int x=12; 3.public void method(intx){ 4.x+=x; 5.System.out.println(x); 6.} 7.} Given: 34.Test t=new Test(); 35.t.method(5); What is the output from line 5 of the Test class?()A5B10C12D17E24
多选题Which two statements are true about the hashCode method?()AThe hashCode method for a given class can be used to test for object equality and object inequality for that class.BThe hashCode method is used by the java.util.SortedSet collection class to order theelements within that set.CThe hashCode method for a given class can be used to test for object inequality, but NOT object equality, for that class.DThe only important characteristic of the values returned by a hashCode method is that the distribution of values must follow a Gaussian distribution.EThe hashCode method is used by the java.util.HashSet collection class to group the elements within that set into hash buckets for swift retrieval.
单选题Given a class Repetition: 1. package utils; 2. 3. public class Repetition { 4. public static String twice(String s) { return s + s; } 5. } and given another class Demo: 1. // insert code here 2. 3. public class Demo { 4. public static void main(String[] args) { 5. System.out.println(twice(”pizza”)); 6. } 7. } Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()A import utils.*;B static import utils.*;C import utils.Repetition.*;D static import utils.Repetition. *;E import utils.Repetition.twice();F import static utils.Repetition.twice;G static import utils.Repetition.twice;
单选题现有: 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 运行时异常被抛出。
单选题Which code should be inserted at line 1 of Demo.java to compile and run Demo toprint "pizzapizza"?()A import utils.*;B static import utils.*;C import utils.Repetition.*;D static import utils.Repetition.*;E import utils.Repetition.twice();F import static utils.Repetition.twice;G static import utils.Repetition.twice;