11. public static void main(String[] args) {  12. Object obj =new int[] { 1,2,3 };  13. int[] someArray = (int[])obj;  14. for (int i: someArray) System.out.print(i +“ “)  15. }  What is the result? ()A、 1 2 3B、 Compilation fails because of an error in l

题目

11. public static void main(String[] args) {  12. Object obj =new int[] { 1,2,3 };  13. int[] someArray = (int[])obj;  14. for (int i: someArray) System.out.print(i +“ “)  15. }  What is the result? ()

  • A、 1 2 3
  • B、 Compilation fails because of an error in line 12.
  • C、 Compilation fails because of an error in line 13.
  • D、 Compilation fails because of an error in line 14.
  • E、 A ClassCastException is thrown at runtime.

相似考题
参考答案和解析
正确答案:A
更多“11. public static&ens”相关问题
  • 第1题:

    10. abstract public class Employee {  11. protected abstract double getSalesAmount();  12. public double getCommision() {  13. return getSalesAmount() * 0.15;  14. }  15. }  16. class Sales extends Employee {  17. // insert method here  18. }  Which two methods, inserted independently at line 17, correctly complete the Sales class?()

    • A、 double getSalesAmount() { return 1230.45; }
    • B、 public double getSalesAmount() { return 1230.45; }
    • C、 private double getSalesAmount() { return 1230.45; }
    • D、 protected double getSalesAmount() { return 1230.45; }

    正确答案:B,D

  • 第2题:

    11. public interface Status {  12. /* insert code here */ int MY_VALUE = 10;  13. }  Which three are valid on line 12?()

    • A、 final
    • B、 static
    • C、 native
    • D、 public
    • E、 private
    • F、 abstract
    • G、 protected

    正确答案:A,B,D

  • 第3题:

    多选题
    Given:   11. // insert code here   12. private N min, max;   13. public N getMin() { return min; }   14. public N getMax() { return max; }   15. public void add(N added) {   16. if (min == null || added.doubleValue()  max.doubleValue())  19. max = added;   20. }   21. }   Which two, inserted at line 11, will allow the code to compile?()
    A

    A

    B

    B

    C

    C

    D

    D

    E

    E

    F

    F


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

  • 第4题:

    单选题
    10. interface Foo { int bar(); }  11. public class Sprite {  12. public int fubar( Foo foo) { return foo.bar(); }  13. public void testFoo() {  14. fubar(  15. // insert code here  16.);  17. }  18. }  Which code, inserted at line 15, allows the class Sprite to compile?()
    A

     Foo { public int bar() { return 1; } }

    B

     new Foo { public int bar() { return 1; } }

    C

     newFoo() { public int bar(){return 1; } }

    D

     new class Foo { public int bar() { return 1; } }


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

  • 第5题:

    多选题
    A JavaBeans component has the following field:  11. private boolean enabled;  Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()
    A

    public void setEnabled( boolean enabled) public boolean getEnabled()

    B

    public void setEnabled( boolean enabled) public void isEnabled()

    C

    public void setEnabled( boolean enabled) public boolean isEnabled()

    D

    public boolean setEnabled( boolean enabled) public boolean getEnabled()


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

  • 第6题:

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


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

  • 第7题:

    单选题
    1. public class test (  2. public static void main(string args[]) {  3. int 1= 0;  4. while (i)  {  5. if (i==4) {  6. break;  7. }  8. ++i;  9. }  10.    11. }  12. )   What is the value of i at line 10?()
    A

     0

    B

     3

    C

     4

    D

     5

    E

     The code will not compile.


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

  • 第8题:

    单选题
    10. public class ClassA {  11. public void methodA() {  12. ClassB classB = new ClassB();  13. classB.getValue();  14. }  15. }  And:  20. class ClassB {  21. public ClassC classC;  22.  23. public String getValue() {  24. return classC.getValue();  25. }  26. }  And:  30. class ClassC {  31. public String value;  32.  33. public String getValue() {  34. value = “ClassB”;  35. return value;  36. }  37. }  Given:  ClassA a = new ClassA();  a.methodA();  What is the result?()
    A

     Compilation fails.

    B

     ClassC is displayed.

    C

     The code runs with no output.

    D

     An exception is thrown at runtime.


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

  • 第9题:

    单选题
    11. public class Test {  12. public void foo() {  13. assert false;  14. assert false;  15. }  16. public void bar(){  17. while(true){  18. assert false;  19. }  20. assert false;  21. }  22. }  What causes compilation to fail?()
    A

     Line 13

    B

     Line 14

    C

     Line 18

    D

     Line 20


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

  • 第10题:

    单选题
    1. class Pizza {  2. java.util.ArrayList toppings;  3. public final void addTopping(String topping) {  4. toppings.add(topping); 5. }  6. }  7. public class PepperoniPizza extends Pizza {  8. public void addTopping(String topping) {  9. System.out.println(”Cannot add Toppings”);  10. }  11. public static void main(String[] args) {  12. Pizza pizza = new PepperoniPizza();  13. pizza.addTopping(”Mushrooms”);  14. }  15. }  What is the result?()
    A

     Compilation fails.

    B

     Cannot add Toppings

    C

     The code runs with no output.

    D

     A NullPointerException is thrown in Line 4.


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

  • 第11题:

    A JavaBeans component has the following field:  11. private boolean enabled;  Which two pairs of method declarations follow the JavaBeans standard for accessing this field?()

    • A、 public void setEnabled( boolean enabled) public boolean getEnabled()
    • B、 public void setEnabled( boolean enabled) public void isEnabled()
    • C、 public void setEnabled( boolean enabled) public boolean isEnabled()
    • D、 public boolean setEnabled( boolean enabled) public boolean getEnabled()

    正确答案:A,C

  • 第12题:

    10. class Line {  11. public class Point { public int x,y; }  12. public Point getPoint() { return new Point(); }  13. }  14. class Triangle {  15. public Triangle() {  16. // insert code here  17. }  18. }  Which code, inserted at line 16, correctly retrieves a local instance of a Point object?() 

    • A、 Point p = Line.getPoint();
    • B、 Line.Point p = Line.getPoint();
    • C、 Point p = (new Line()).getPoint();
    • D、 Line.Point p = (new Line()).getPoint();

    正确答案:D

  • 第13题:

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

     peep

    B

     bark

    C

     meow

    D

     Compilation fails.

    E

     An exception is thrown at runtime.


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

  • 第14题:

    单选题
    1. public class SimpleCalc {  2. public int value;  3. public void calculate() { value += 7; }  4. } And:  1. public class MultiCalc extends SimpleCalc {  2. public void calculate() { value -= 3; }  3. public void calculate(int multiplier) {  4. calculate();  5. super.calculate();  6. value *=multiplier;  7. }  8. public static void main(String[] args) {  9. MultiCalc calculator = new MultiCalc();  10. calculator.calculate(2);  11. System.out.println(”Value is: “+ calculator.value);  12. }  13. }  What is the result?()
    A

     Value is: 8

    B

     Compilation fails.

    C

     Value is: 12

    D

     Value is: -12

    E

     The code runs with no output.

    F

     An exception is thrown at runtime.


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

  • 第15题:

    单选题
    10. class Line {  11. public class Point { public int x,y; }  12. public Point getPoint() { return new Point(); }  13. }  14. class Triangle {  15. public Triangle() {  16. // insert code here  17. }  18. }  Which code, inserted at line 16, correctly retrieves a local instance of a Point object?()
    A

     Point p = Line.getPoint();

    B

     Line.Point p = Line.getPoint();

    C

     Point p = (new Line()).getPoint();

    D

     Line.Point p = (new Line()).getPoint();


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

  • 第16题:

    单选题
    10. public class ClassA {  11. public void count(int i) {  12. count(++i);  13. }  14. }  And:  20. ClassA a = new ClassA();  21. a.count(3);  Which exception or error should be thrown by the virtual machine?()
    A

     StackOverflowError

    B

     NullPointerException

    C

     NumberFormatException

    D

     IllegalArgumentException

    E

     ExceptionlnlnitializerError


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

  • 第17题:

    多选题
    1. class Super {  2. private int a;  3. protected Super(int a) { this.a = a; }  4. }  .....  11. class Sub extends Super {  12. public Sub(int a) { super(a); }  13. public Sub() { this.a= 5; }  14. }  Which two, independently, will allow Sub to compile?()
    A

    Change line 2 to: public int a;

    B

    Change line 2 to: protected int a;

    C

    Change line 13 to: public Sub() { this(5); }

    D

    Change line 13 to: public Sub() { super(5); }

    E

    Change line 13 to: public Sub() { super(a); }


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

  • 第18题:

    单选题
    10. class Nav{  11. public enum Direction { NORTH, SOUTH, EAST, WEST }  12. }  13. public class Sprite{  14. // insert code here  15. }  Which code, inserted at line 14, allows the Sprite class to compile?()
    A

     Direction d = NORTH;

    B

     Nav.Direction d = NORTH;

    C

     Direction d = Direction.NORTH;

    D

     Nav.Direction d = Nav.Direction.NORTH;


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

  • 第19题:

    多选题
    Given an EL function declared with:11.  12.spin 13.com.example.Spinner 14. 15.java.lang.String spinIt() 16. 17. Which two are true?()
    A

    The function method must have the signature: public String spin().

    B

    The method must be mapped to the logical name spin in the web.xml file.

    C

    The function method must have the signature: public String spinIt().

    D

    The function method must have the signature public static String spin().

    E

    The function method must have the signature: public static String spinIt().

    F

    The function class must be named Spinner, and must be in the package com.example.


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

  • 第20题:

    多选题
    11. public interface Status {  12. /* insert code here */ int MY_VALUE = 10;  13. }  Which three are valid on line 12?()
    A

    final

    B

    static

    C

    native

    D

    public

    E

    private

    F

    abstract

    G

    protected


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