package com.sun.sjcp; public class Commander{ public static void main(String[]args){ //more code here } } Assume that the class fileis located in /foo/com/sun/sjcp/,the current directory is/foo/,and that the classpath contains“.“(current directory). Whic

题目

package com.sun.sjcp; public class Commander{ public static void main(String[]args){ //more code here } } Assume that the class fileis located in /foo/com/sun/sjcp/,the current directory is/foo/,and that the classpath contains“.“(current directory). Which command line correctly runs Commander?()

  • A、java Commander
  • B、java com.sim.sjcp.Commander
  • C、java com/sun/sjcp/Commander
  • D、java-cpcom.sun.sjcp Commander
  • E、java-cpcom/sun/sjcp Commander

相似考题
更多“package com.sun.sjcp; public cl”相关问题
  • 第1题:

    下列哪个选项的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 { }


    正确答案:B

  • 第2题:

    下列带下画线的标识符,符合Java命名约定的是 A) B)

    C) D)

    A.package com.Bi.hr

    B.public class xyz

    C.int I

    D.void setCustomerName()


    正确答案:D
    解析:本题主要考查在Java中标识符是赋予变量、对象、类和方法的名称。标识符可以由字母、数字、下画线“-”和美元符“$”组成,但数字不能开头,不能用关键字作标识符。类名和接口名都采用完整的英文描述符,并且所有单词的第一个字母大写;变量和方法名采用完整的英文描述符,第一个字母小写,任何中间的单词首字母大写;包采用完整的英文描述符,且都是由小写字母组成。(参见Java编程规范)

  • 第3题:

    Which will declare a method that is available to all members of the same package and can be referenced  without an instance of the class?()  

    • A、 Abstract public void methoda();
    • B、 Public abstract double methoda();
    • C、 Static void methoda(double d1){}
    • D、 Public native double methoda(){}
    • E、 Protected void methoda(double d1){}

    正确答案:C

  • 第4题:

    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 = 0
    • B、 x = 42
    • C、 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.

    正确答案:C

  • 第5题:

    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.

    正确答案:C

  • 第6题:

    Given a correctly compiled class whose source code is:  package com.sun.sjcp;  public class Commander {  public static void main(String[] args) {  // more code here  }  }  Assume that the class file is located in /foo/com/sun/sjcp/, the current directory is /foo/, and that the classpath contains “.“ (current directory). Which command line correctly runs Commander?() 

    • A、 java Commander
    • B、 java com. sim. sjcp.Commander
    • C、 java com/sun/sjcp/Commander
    • D、 java -cp com.sun.sjcp Commander
    • E、 java -cp com/sun/sjcp Commander

    正确答案:B

  • 第7题:

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


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

  • 第8题:

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


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

  • 第9题:

    单选题
    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()”


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

  • 第10题:

    单选题
    package test; class Target{ public String name="hello"; } What can directly access and change the value of the variable name?()
    A

    any class

    B

    only the Target class

    C

    any class in the test package

    D

    any class that extends Target


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

  • 第11题:

    单选题
    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) {}


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

  • 第12题:

    单选题
    Given a correctly compiled class whose source code is:  package com.sun.sjcp;  public class Commander {  public static void main(String[] args) {  // more code here  }  }  Assume that the class file is located in /foo/com/sun/sjcp/, the current directory is /foo/, and that the classpath contains “.“ (current directory). Which command line correctly runs Commander?()
    A

     java Commander

    B

     java com. sim. sjcp.Commander

    C

     java com/sun/sjcp/Commander

    D

     java -cp com.sun.sjcp Commander

    E

     java -cp com/sun/sjcp Commander


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

  • 第13题:

    有如下程序:includeusing namespace std;class C1{public:~Cl( ){cout<<1;}};class C

    有如下程序: #include<iostream> using namespace std; class C1{ public: ~Cl( ){cout<<1;} }; class C2:public C1{ public: ~C2( ){cout<<2;} }; int main( ){ C2 cb2; C1*cb1: return 0; } 程序的输出结果是

    A.121

    B.21

    C.211

    D.12


    正确答案:B
    解析:对象的派生撤销时,先调用派生类析构函数,然后调用基类析构函数,故答案为B。

  • 第14题:

    IPAC是以下哪个词组的缩略语()

    • A、Internet Public Access Catalog
    • B、Internal Public Access Catalog
    • C、Internet Package Access Catalog
    • D、Internet Public Available Catalog

    正确答案:A

  • 第15题:

    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) {}

    正确答案:C

  • 第16题:

    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()”

    正确答案:A

  • 第17题:

    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.

    正确答案:E

  • 第18题:

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


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

  • 第19题:

    单选题
    package com.sun.sjcp; public class Commander{ public static void main(String[]args){ //more code here } } Assume that the class fileis located in /foo/com/sun/sjcp/,the current directory is/foo/,and that the classpath contains“.“(current directory). Which command line correctly runs Commander?()
    A

    java Commander

    B

    java com.sim.sjcp.Commander

    C

    java com/sun/sjcp/Commander

    D

    java-cpcom.sun.sjcp Commander

    E

    java-cpcom/sun/sjcp Commander


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

  • 第20题:

    单选题
    下列Java源程序结构中前三种语句的次序,正确的是(  )。
    A

    import,package,public class

    B

    import必为首,其他不限

    C

    public class,package,import

    D

    package,import,public class


    正确答案: A
    解析:
    Java程序中源代码结构:①package语句,0或1个,用于指定文件存入所指定的包中,该语句必须在文件之首;②import语句,0或多个,必须在所有类定义之前引入标准类;③public class Definition(公共类定义),0或1个,指定应用程序类名,与源文件名一致;④class Definiton,0或多个,类定义;⑤interface Definition,0或多个,接口定义。

  • 第21题:

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

    B

     x = 42

    C

     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.


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

  • 第22题:

    单选题
    Which will declare a method that is available to all members of the same package and can be referenced without an instance of the class?()
    A

     Abstract public void methoda();

    B

     Public abstract double methoda();

    C

     Static void methoda(double d1){}

    D

     Public native double methoda()  {}

    E

     Protected void methoda(double d1)  {}


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

  • 第23题:

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


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

  • 第24题:

    单选题
    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
    解析: 暂无解析