10. class Line {  11. public static class Point { }  12. } 

题目
单选题
10. class Line {  11. public static class Point { }  12. }  13.  14. class Triangle {  15. // insert code here  16. }  Which code, inserted at line 15, creates an instance of the Point class defined in Line?()
A

 Point p = new Point();

B

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

C

 The Point class cannot be instatiated at line 15.

D

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

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

11. public class Counter {  12. public static void main(String[] args) {  13. int numArgs = /* insert code here */;  14. }  15. }  and the command line: java Counter one fred 42 Which code, inserted at line 13, captures the number of arguments passed into the program?() 

  • A、 args.count
  • B、 args.length
  • C、 args.count()
  • D、 args.length()
  • E、 args.getLength()

正确答案:B

第2题:

11. static class A {  12. void process() throws Exception { throw new Exception(); }  13. }  14. static class B extends A {  15. void process() { System.out.println(”B”); }  16. }  17. public static void main(String[] args) {  18. new B().process();  19. }  What is the result?() 

  • A、 B
  • B、 The code runs with no output.
  • C、 Compilation fails because of an error in line 12.
  • D、 Compilation fails because of an error in line 15.
  • E、 Compilation fails because of an error in line 18.

正确答案:A

第3题:

Class TestException  1. public class TestException extends Exception {  2. } Class a:  1. public class a {  2.  3. public String sayHello(String name) throws TestException {  4.  5. if(name == null) {  6. throw new TestException();  7. }  8.  9. return “Hello “+ name;  10. }  11.  12. }  A programmer wants to use this code in an application: 45. A a=new A();  46. System.out.println(a.sayHello(”John”));  Which two are true?()

  • A、 Class a will not compile.
  • B、 Line 46 can throw the unchecked exception TestException.
  • C、 Line 45 can throw the unchecked exception TestException.
  • D、 Line 46 will compile if the enclosing method throws a TestException.
  • E、 Line 46 will compile if enclosed in a try block, where TestException is caught.

正确答案:D,E

第4题:

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.

正确答案:E

第5题:

10. public class SuperCaic {  11. protected static int multiply(int a, int b) { return a * b; }  12. }  and:  20. public class SubCalc extends SuperCalc {  21. public static int multiply(int a, int b) {  22. int c = super.multiply(a, b);  23. return c;  24. }  25. }  and:  30. SubCalc sc = new SubCalc();  31. System.out.println(sc.multiply(3,4));  32. System.out.println(SubCalc.multiply(2,2));  What is the result?()

  • A、 12 4
  • B、 The code runs with no output.
  • C、 An exception is thrown at runtime.
  • D、 Compilation fails because of an error in line 21.
  • E、 Compilation fails because of an error in line 22.
  • F、 Compilation fails because of an error in line 31.

正确答案:E

第6题:

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

第7题:

public class OuterClass {  private double d1  1.0;  //insert code here   }   You need to insert an inner class declaration at line2. Which two inner class declarations are valid?() 

  • A、 static class InnerOne {  public double methoda() {return d1;}  }
  • B、 static class InnerOne {  static double methoda() {return d1;} }
  • C、 private class InnerOne {  public double methoda() {return d1;} }
  • D、 protected class InnerOne {  static double methoda() {return d1;} }
  • E、 public abstract class InnerOne {  public abstract double methoda();  }

正确答案:C,E

第8题:

10. class Line {  11. public static class Point { }  12. }  13.  14. class Triangle {  15. // insert code here  16. }  Which code, inserted at line 15, creates an instance of the Point class defined in Line?() 

  • A、 Point p = new Point();
  • B、 Line.Point p = new Line.Point();
  • C、 The Point class cannot be instatiated at line 15.
  • D、 Line 1 = new Line() ; 1.Point p = new 1.Point();

正确答案:B

第9题:

10. interface Foo {}  11. class Alpha implements Foo {}  12. class Beta extends Alpha {}  13. class Delta extends Beta {  14. public static void main( String[] args) {  15. Beta x = new Beta();  16. // insert code here  17. }  18. }  Which code, inserted at line 16, will cause a java.lang.ClassCastException?() 

  • A、 Alpha a = x;
  • B、 Foo f= (Delta)x;
  • C、 Foo f= (Alpha)x;
  • D、 Beta b = (Beta)(Alpha)x;

正确答案:B

第10题:

1. public class A {  2.  3. private int counter = 0;  4.  5. public static int getInstanceCount() {  6. return counter;  7. }  8.  9. public A() {  10. counter++;  11. }  12.  13. }  Given this code from Class B:  25.A a1 =new A();  26. A a2 =new A();  27. A a3 =new A();  28. System.out.printIn(A.getInstanceCount() ); What is the result?() 

  • A、 Compilation of class A fails.
  • B、 Line 28 prints the value 3 to System.out.
  • C、 Line 28 prints the value 1 to System.out.
  • D、 A runtime error occurs when line 25 executes.
  • E、 Compilation fails because of an error on line 28.

正确答案:A

更多相关问题