网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)
单选题
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.


参考答案

参考解析
解析: 暂无解析
更多 “单选题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.” 相关考题
考题 下列Java源程序结构中前三种语句的次序,正确的是A.import, package, public classB.import必为首,其他不限C.public class, import, packageD.package, import, public class

考题 package test;class Target{public String name=hello;}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

考题 如下两个源程序文件,分别编译后,运行Example.class文件,运行结果为______。AB.java文件代码如下;package test;public class AB{int a=60;public void show(){System.out.println(”a=”+a);}Example.java文件代码如下:import test.AB;class Example{public static void main(String args[]){AB bj=new AB();obj.show();}}

考题 下列哪个选项的java源文件代码片段是不正确的?A.package testpackage; public class Test{ }B.import java. io. *; package testpaekage; public class Test { }C.import java.io.*; class Person { } public class Test { }D.import java.io.*; import java. awt.*; public class Test{ }

考题 下列带下画线的标识符符合Java命名约定的是A.package com.Bi.hrB.public class xyzC.intID.void setCustomerName()

考题 下列哪个选项的java源文件程序段是不正确的? ( )A.package testpackage; public class Test{ }B.import java.io.*; package testpackage; public class Test{ }C.import java.i.*; class Person{} public class Test{ }D.import java.io.*; import java.awt.*; public class Test { }

考题 给出下列java源代码:  //Point x  Public class Interesting{}  在源代码//point x处添加()能符合java语法 A、import java.awt.*B、package local.utilC、class MoreInteresting{}D、protected class MoreInteresting{}

考题 Which will declare a method that is available to all members of the same package and be referenced without an instance of the class?()A、 abstract public void methoda ();B、 public abstract double inethoda ();C、 static void methoda (double dl) {}D、 public native double methoda () {}E、 protected void methoda (double dl) {}

考题 package test1;  public class Test1 {  static int x = 42;  }  package test2;  public class Test2 extends test1.Test1 {  public static void main(String[] args) { System.out.println(“x = “ + x);  }  }  What is the result?() A、 x = 0B、 x = 42C、 Compilation fails because of an error in line 2 of class Test2.D、 Compilation fails because of an error in line 3 of class Test1.E、 Compilation fails because of an error in line 4 of class Test2.

考题 在单一文件中import、class和package的正确出现顺序是()A、package,import,classB、class,import,packageC、import,package,classD、package,class,import

考题 package foo; public class Outer (  public static class Inner (  )  )   Which statement is true? () A、 An instance of the Inner class can be constructed with “new Outer.Inner ()”B、 An instance of the inner class cannot be constructed outside of package foo.C、 An instance of the inner class can only be constructed from within the outer class.D、 From within the package bar, an instance of the inner class can be constructed with “new inner()”

考题 package geometry;  public class Hypotenuse {  public InnerTriangle it = new InnerTriangle();  class InnerTriangle {  public int base;  public int height;  }  }  Which 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.

考题 ClassOne.java: 1. package com.abe.pkg1; 2. public class ClassOne { 3. private char var = ‘a’; 4. char getVar() { return var; } 5. } ClassTest.java: 1. package com.abe.pkg2; 2. import com.abc.pkg1.ClassOne; 3. public class ClassTest extends ClassOne { 4. public static void main(String[] args) { 5. char a = new ClassOne().getVar();6. char b = new ClassTest().getVar(); 7. } 8. } What is the result?()A、 Compilation fails.B、 Compilation succeeds and no exceptions are thrown.C、 An exception is thrown at line 5 in ClassTest.java.D、 An exception is thrown at line 6 in ClassTest.java.

考题 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.

考题 单选题ClassOne.java  1. package com.abc.pkg1;  2. public class ClassOne {  3. private char var = ‘a’;   4. char getVar()  {return var;}  5. }  ClassTest.java    1. package com.abc.pkg2;  2. import com.abc.pkg1.ClassOne;  3. public class ClassTest extends ClassOne {  4.   public static void main(String[]args)  {  5.     char a = new ClassOne().getVar();  6.     char b = new ClassTest().getVar();   7.   }  8. }      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.

考题 单选题It is desirable that a certain method within a certain class can only be accessed by classes that are defined within the same package as the class of the method. How can such restrictions be enforced?()A Mark the method with the keyword public.B Mark the method with the keyword protected.C Mark the method with the keyword private.D Mark the method with the keyword package.E Do not mark the method with any accessibility modifiers.

考题 单选题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?()A any classB only the Target classC any class in the test packageD any class that extends Target

考题 单选题package geometry;  public class Hypotenuse {  public InnerTriangle it = new InnerTriangle();  class InnerTriangle {  public int base;  public int height;  }  }  Which 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 classes defined in two different files:  1. package util;  2. public class BitUtils {  3. public static void process(byte[]) { /* more code here */ }  4. }  1. package app;  2. public class SomeApp {  3. public static void main(String[] args) {  4. byte[] bytes = new byte[256];  5. // insert code here  6. }  7. }  What is required at line 5 in class SomeApp to use the process method of BitUtils?()A  process(bytes);B  BitUtils.process(bytes);C  util.BitUtils.process(bytes);D  SomeApp cannot use methods in BitUtils.E  import util.BitUtils.*; process(bytes);

考题 单选题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?()A any classB only the Target classC any class in the test packageD any class that extends Target

考题 单选题下列Java源程序结构中前三种语句的次序,正确的是(  )。A import,package,public classB import必为首,其他不限C public class,package,importD package,import,public class

考题 单选题package foo; public class Outer (  public static class Inner (  )  )   Which statement is true? ()A  An instance of the Inner class can be constructed with “new Outer.Inner ()”B  An instance of the inner class cannot be constructed outside of package foo.C  An instance of the inner class can only be constructed from within the outer class.D  From within the package bar, an instance of the inner class can be constructed with “new inner()”

考题 单选题package test1;  public class Test1 {  static int x = 42;  }  package test2;  public class Test2 extends test1.Test1 {  public static void main(String[] args) { System.out.println(“x = “ + x);  }  }  What is the result?()A  x = 0B  x = 42C  Compilation fails because of an error in line 2 of class Test2.D  Compilation fails because of an error in line 3 of class Test1.E  Compilation fails because of an error in line 4 of class Test2.

考题 单选题package test; class Target{ public String name="hello"; } 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

考题 单选题Which will declare a method that is available to all members of the same package and be referenced without an instance of the class?()A  abstract public void methoda ();B  public abstract double inethoda ();C  static void methoda (double dl) {}D  public native double methoda () {}E  protected void methoda (double dl) {}

考题 单选题package foo;  public class Outer {  public static class Inner {  }  }   Which statement is true?()A  Compilation fails.B  An instance of the Inner class can be constructed with “new Outer.Inner()”.C  An instance of the Inner class cannot be constructed outside of package foo.D  An instance of the Inner class can be constructed only from within the Outer class.E  From within the package foo, and instance of the Inner class can be constructed with “new Inner()”.

考题 单选题package test;  class Target {  public String name = “hello”;  }  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