单选题12. String csv = “Sue,5,true,3”;  13. Scanner scanner = new Scanner( csv);  14. scanner.useDelimiter(”,”);  15. int age = scanner.nextInt();  What is the result?()ACompilation fails.BAfter line 15, the value of age is 5.CAfter line 15, the value of age

题目
单选题
12. String csv = “Sue,5,true,3”;  13. Scanner scanner = new Scanner( csv);  14. scanner.useDelimiter(”,”);  15. int age = scanner.nextInt();  What is the result?()
A

 Compilation fails.

B

 After line 15, the value of age is 5.

C

 After line 15, the value of age is 3.

D

 An exception is thrown at runtime.


相似考题
参考答案和解析
正确答案: B
解析: 暂无解析
更多“12. String csv = “Sue,5,true,3”;  13. Scanner scanner = new ”相关问题
  • 第1题:

    多选题
    1. import java.util.*;  2. public class Test {  3. public static void main(String[] args) {  4. List strings = new ArrayList();  5. // insert code here  6. }  7. }  Which four, inserted at line 5, will allow compilation to succeed?()
    A

    String s = strings.get(0);

    B

    Iterator i1 = strings.iterator();

    C

    String[] array1 = strings.toArray();

    D

    Iterator i2 = strings.iterator();

    E

    String[] array2 = strings.toArray(new String[1]);

    F

    Iterator i3 = strings.iterator();


    正确答案: A,C
    解析: 暂无解析

  • 第2题:

    单选题
    Given the following code:     if (x>0) {  System.out.println("first");  }     else if (x>-3) {  System.out.println("second");  }     else {  System.out.println("third");  }  Which range of x value would print the string "second"?()
    A

     x > 0

    B

     x > -3

    C

     x <= -3

    D

     x <= 0 & x > -3


    正确答案: C
    解析: x>0时打印"first",x>-3&&x<=0时打印"second",x<=-3时打印"third"。这个题目没有什么难的,只要理解if语句的语法就可以了。

  • 第3题:

    多选题
    A team of programmers is reviewing a proposed API for a new utility class.After some discussion, they realize that they can reduce the number of methods in the API without losing any functionality.If they implement the new design, which two principles will they be promoting?()
    A

    Looser coupling

    B

    Tighter coupling

    C

    Lower cohesion

    D

    Higher cohesion

    E

    Weaker encapsulation

    F

    Stronger encapsulation


    正确答案: D,B
    解析: 暂无解析

  • 第4题:

    单选题
    public class SwitchTest {   public static void main (String args) {   System.out.PrintIn(“value =” +switchIt(4));   }   public static int switchIt(int x) {   int j = 1;   switch (x) {   case 1: j++;   case 2: j++;   case 3: j++;  case 4: j++;   case 5: j++;   default:j++;   }   return j + x;   }   }   What is the output from line 3? ()
    A

     Value = 3

    B

     Value = 4

    C

     Value = 5

    D

     Value = 6

    E

     Value = 7

    F

     Value = 8


    正确答案: C
    解析: 暂无解析

  • 第5题:

    单选题
    ClassOne.java   package com.abc.pkg1;   public class ClassOne {   private char var = ‘a‘;   char getVar() {return var;}   }   ClassTest.java   package com.abc.pkg2;   import com.abc.pkg1.ClassOne;   public class ClassTest extends ClassOne {  public static void main(Stringargs) {  char a = new ClassOne().getVar();  char b = new ClassTest().getVar();   }   }   What is the result?()
    A

     Compilation will fail.

    B

     Compilation succeeds and no exceptions are thrown.

    C

     Compilation succeeds but an exception is thrown at line 5 in ClassTest.java.

    D

     Compilation succeeds but an exception is thrown at line 6 in ClassTest.java.


    正确答案: B
    解析: 暂无解析

  • 第6题:

    单选题
    public class Wow {  public static void go(short n) {System.out.println(”short”); }  public static void go(Short n) {System.out.println(”SHORT”);}  public static void go(Long n) {System.out.println(” LONG”); }  public static void main(String [] args) {  Short y= 6;  int z=7;  go(y);  go(z);  }  }  What is the result?()
    A

     short LONG

    B

     SHORT LONG

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


    正确答案: B
    解析: 暂无解析

  • 第7题:

    多选题
    Which two demonstrate encapsulation of data? ()
    A

    Member data have no access modifiers.

    B

    Member data can be modified directly.

    C

    The access modifier for methods is protected.

    D

    The access modifier to member data is private.

    E

    Methods provide for access and modification of data.


    正确答案: A,B
    解析: 暂无解析

  • 第8题:

    多选题
    Which two cause a compiler error?()
    A

    float[] = new float(3);

    B

    float f2[] = new float[];

    C

    float[] f1 = new float[3];

    D

    float f3[] = new float[3];

    E

    float f5[] = { 1.0f, 2.0f, 2.0f };

    F

    float f4[] = new float[] { 1.0f. 2.0f. 3.0f};


    正确答案: C,D
    解析: The F. statement is incorrect. The float numbers should be separated with commas and not dots.

  • 第9题:

    多选题
    Which two create an instance of an array?()
    A

    int ia = new int [15];

    B

    float fa = new float [20];

    C

    char ca = “Some String”;

    D

    Object oa = new float[20];

    E

    Int ia = (4, 5, 6) (1, 2, 3)


    正确答案: B,E
    解析: 暂无解析

  • 第10题:

    多选题
    Which two CANNOT directly cause a thread to stop executing?()
    A

    Calling the yield method.

    B

    Calling the wait method on an object.

    C

    Calling the notify method on an object.

    D

    Calling the notifyAll method on an object.

    E

    Calling the start method on another Thread object.


    正确答案: C,D
    解析: 暂无解析

  • 第11题:

    单选题
    public class Foo {  public void main (String [] args)   {  system.out.printIn(“Hello World.”); } }  What is the result?()
    A

     An exception is thrown.

    B

     The code does no compile.

    C

     “Hello World.” Is printed to the terminal.

    D

     The program exits without printing anything.


    正确答案: A
    解析: 暂无解析

  • 第12题:

    单选题
    Which statement is true?()
    A

     If only one thread is blocked in the wait method of an object, and another thread executes the modify on that same object, then the first thread immediately resumes execution.

    B

     If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, it is still possible that the first thread might never resume execution.

    C

     If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, then the first thread definitely resumes execution as a direct and sole  consequence of the notify call.

    D

     If two threads are blocked in the wait method of one object, and another thread executes the notify method on the same object, then the first thread that executed the wait call first definitely resumes execution as a direct and sole consequence of the notify call.


    正确答案: C
    解析: 暂无解析

  • 第13题:

    单选题
    1. public class A {  2. public String doit(int x, int y) {  3. return “a”;  4. }  5.  6. public String doit(int... vals) {  7. return “b”;  8. } 9. }  Given:  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
    解析: 暂无解析

  • 第14题:

    单选题
    class A {   public byte getNumber () {   return 1;   }   }   class B extends A {   public short getNumber() {   return 2;   }    public static void main (String args) {   B b = new B ();    System.out.printIn(b.getNumber())  }   }   What is the result?()
    A

     Compilation succeeds and 1 is printed.

    B

     Compilation succeeds and 2 is printed.

    C

     An error at line 8 causes compilation to fail.

    D

     An error at line 14 causes compilation to fail.

    E

     Compilation succeeds but an exception is thrown at line 14.


    正确答案: D
    解析: 暂无解析

  • 第15题:

    多选题
    class A {  protected int method1(int a, int b) { return 0; }  }  Which two are valid in a class that extends class A?()
    A

    public int method1(int a, int b) { return 0; }

    B

    private int method1(int a, int b) { return 0; }

    C

    private int method1(int a, long b) { return 0; }

    D

    public short method1(int a, int b) { return 0: }

    E

    static protected int method1(int a, int b) { return 0; }


    正确答案: D,B
    解析: 暂无解析

  • 第16题:

    单选题
    20. public float getSalary(Employee e) {  21. assert validEmployee(e);  22. float sal = lookupSalary(e);  23. assert (sal>0);  24. return sal;  25. }  26. private int getAge(Employee e) {  27. assert validEmployee(e);  28. int age = lookupAge(e);  29. assert (age>0);  30. return age;  31. }  Which line is a violation of appropriate use of the assertion mechanism?()
    A

     line 21

    B

     line 23

    C

     line 27

    D

     line 29


    正确答案: A
    解析: 暂无解析

  • 第17题:

    单选题
    public class X {  public static void main(String [] args) {  try {  badMethod();  System.out.print(“A”); }  catch (Exception ex) {  System.out.print(“B”);  }  finally {  System.out.print(“C”);  }  System.out.print(“D”);  }   public static void badMethod() {} }  What is the result?()
    A

     AC

    B

     BD

    C

     ACD

    D

     ABCD

    E

     Compilation fails.


    正确答案: A
    解析: 暂无解析

  • 第18题:

    单选题
    public class Yikes {  public static void go(Long n) {System.out.println(”Long “);}  public static void go(Short n) {System.out.println(”Short “);}  public static void go(int n) {System.out.println(”int “);}  public static void main(String [] args) {  short y= 6;  long z= 7;  go(y);  go(z);  }  }  What is the result?()
    A

     int Long

    B

     Short Long

    C

     Compilation fails.

    D

     An exception is thrown at runtime.


    正确答案: D
    解析: 暂无解析

  • 第19题:

    单选题
    int i = 1,j = 10;  do{  if (i>j) {  continue;  }  j--;  } while (++i <6);  System.out.println(“i = “ +i+” and j = “+j);  What is the result?()
    A

     i = 6 and j = 5

    B

     i = 5 and j = 5

    C

     i = 6 and j = 4

    D

     i = 5 and j = 6

    E

     i = 6 and j = 6


    正确答案: A
    解析: 暂无解析

  • 第20题:

    多选题
    Which two are equivalent?()
    A

    3/2

    B

    3<2

    C

    3*4

    D

    3<<2

    E

    3*2^2

    F

    3<<<2


    正确答案: D,A
    解析: 暂无解析

  • 第21题:

    单选题
    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;


    正确答案: D
    解析: 暂无解析

  • 第22题:

    单选题
    public class test (   public static void main(string args) {   int 1= 0;   while (i) {   if (i==4) {   break;  }   ++i;  }   }   )   What is the value of i at line 10?()
    A

     0

    B

     3

    C

     4

    D

     5

    E

     The code will not compile.


    正确答案: A
    解析: 暂无解析

  • 第23题:

    单选题
    1. interface A { public void aMethod(); }  2. interface B { public void bMethod(); }  3. interface C extends A,B { public void cMethod(); }  4. class D implements B {  5. public void bMethod() { }  6. }  7. class E extends D implements C {  8. public void aMethod() { }  9. public void bMethod() { }  10. public void cMethod() { }  11. }  What is the result?()
    A

     Compilation fails because of an error in line 3.

    B

     Compilation fails because of an error in line 7.

    C

     Compilation fails because of an error in line 9.

    D

     If you define D e = new E(), then e.bMethod() invokes the version of bMethod()defined in Line 5.

    E

     If you define D e = (D)(new E()),then e.bMethod() invokes the version of bMethod() defined in Line 5.

    F

     If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.


    正确答案: C
    解析: 暂无解析

  • 第24题:

    单选题
    Which gets the name of the parent directory file “file.txt”?()
    A

     String name= File.getParentName(“file.txt”);

    B

     String name= (new File(“file.txt”)).getParent();

    C

     String name = (new File(“file.txt”)).getParentName();

    D

     String name= (new File(“file.txt”)).getParentFile();

    E

     Directory dir=(new File (“file.txt”)).getParentDir();  String name= dir.getName();


    正确答案: E
    解析: 暂无解析