单选题下列有关类声明的代码片段,哪一项是正确的?()Aimport java.sql.*; package school; class Student{ }Bpackage school; import java.sql.*; class Student{ }Cpackage school; class Student{ } import java.sql.*;Dpackage school; import java.sql.*;private String name; class Student{ }

题目
单选题
下列有关类声明的代码片段,哪一项是正确的?()
A

 import java.sql.*; package school; class Student{ }

B

 package school; import java.sql.*; class Student{ }

C

 package school; class Student{ } import java.sql.*;

D

 package school; import java.sql.*;private String name; class Student{ }


相似考题
参考答案和解析
正确答案: A
解析: 暂无解析
更多“单选题下列有关类声明的代码片段,哪一项是正确的?()A  import java.sql.*; package school; class Student{ }B  package school; import java.sql.*; class Student{ }C  package school; class Student{ } import java.sql.*;D  package school; import java.sql.*;private String name; class Stu”相关问题
  • 第1题:

    现有如F包结构:      com     |一一X      |    |一一Alpha.class     |    |      |    |一一y      I         |一一Beta.class     |      |l-- Gamma.class    和类:      class Test  {  Alpha a;  Beta b; Gamma c;  }  哪三个必须加入到类Test中,以使其通过编译?() 

    • A、 package y;
    • B、 package com;
    • C、 import com.x.y.*;
    • D、 import com.x.*;

    正确答案:B,C,D

  • 第2题:

    给出下列java源代码:  //Point x  Public class Interesting{}  在源代码//point x处添加()能符合java语法 

    • A、import java.awt.*
    • B、package local.util
    • C、class MoreInteresting{}
    • D、protected class MoreInteresting{}

    正确答案:A,B,C

  • 第3题:

    关于语句package com.myschool,叙述错误的是哪一项?()

    • A、该语句必须出现在类声明语句中class Student{}之前
    • B、包名com.myschool对应目录结构com/myschool
    • C、要想引入该包中的所有类,必须使用import com.myschool
    • D、任何类中都必须包括package语句

    正确答案:D

  • 第4题:

    在单一文件中import、class和package的正确出现顺序是()

    • A、package,import,class
    • B、class,import,package
    • C、import,package,class
    • D、package,class,import

    正确答案:A

  • 第5题:

    在JSP中使用JDBC语句访问数据库,正确导入S QL类库的语句是()。 

    • A、<%@ page import=”java.sql.*” %> 
    • B、<%@ page import=” sql.*” %> 
    • C、<%page import=”java.sql.*” %>  
    • D、<%@ import=”java.sql.*” %>

    正确答案:A

  • 第6题:

    下列有关类声明的代码片段,哪一项是正确的?() 

    • A、 import java.sql.*; package school; class Student{ }
    • B、 package school; import java.sql.*; class Student{ }
    • C、 package school; class Student{ } import java.sql.*;
    • D、 package school; import java.sql.*;private String name; class Student{ }

    正确答案:B

  • 第7题:

    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;

    正确答案:F

  • 第8题:

    定义类:      package utils;      public class Rep{  public static String twice (String s){return s+s ;}     }  再定义另一个类Demo:      //insert code here      public class Demo{  public static void main (String[]  args){      System. out .println( twice( "Hello"));      }      }  在第一行插入哪项代码,可以使程序正常编译和执行?()     

    • A、import utils.*;
    • B、 import utils.Rep.*;
    • C、 import static utils.Rep.twice;
    • D、 static import utils.Rep.twice;

    正确答案:C

  • 第9题:

    单选题
    关于语句package com.myschool,叙述错误的是哪一项?()
    A

    该语句必须出现在类声明语句中class Student{}之前

    B

    包名com.myschool对应目录结构com/myschool

    C

    要想引入该包中的所有类,必须使用import com.myschool

    D

    任何类中都必须包括package语句


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

  • 第10题:

    单选题
    一个程序中,package、import、和class的排放次序是()
    A

    package、import、class

    B

    import、package、class

    C

    三者任意

    D

    class在最后,import、package排放次序任意


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

  • 第11题:

    单选题
    定义类:      package utils;      public class Rep{  public static String twice (String s){return s+s ;}     }  再定义另一个类Demo:      //insert code here      public class Demo{  public static void main (String[]  args){      System. out .println( twice( "Hello"));      }      }  在第一行插入哪项代码,可以使程序正常编译和执行?()
    A

    import utils.*;

    B

     import utils.Rep.*;

    C

     import static utils.Rep.twice;

    D

     static import utils.Rep.twice;


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

  • 第12题:

    单选题
    类Student的声明如下:   package com.school class Student{ String name;  int age;  Student(String name,int age){  //code } void study(String subject){ / /code } }  正确调用方法study(String subject)的是哪项?()
    A

    Student stu = new Student(“Tom”,23); stu.study(“数学”);

    B

    Student.study(“数学”);

    C

    Student stu = new Student(“Tom”,23); stu.study();

    D

    Student stu = new Student(“Tom”,23); String result=stu.study(“数学”);


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

  • 第13题:

    一个程序中,package、import、和class的排放次序是()

    • A、package、import、class
    • B、import、package、class
    • C、三者任意
    • D、class在最后,import、package排放次序任意

    正确答案:A

  • 第14题:

    现有包结构:  com |-- x | |-- Alpha.class | | | |-- y | |-- Beta.class | |-- Gamma.class  和类:  //insert code here  import com.*;  import com.x.y.*;  class Test { Alpha a; Beta b; Gamma c; }  哪两行分别插入后可允许代码编译?() 

    • A、package com.;
    • B、import com.x;
    • C、package com.x;
    • D、import com.x.Alpha;

    正确答案:C,D

  • 第15题:

    现有如下包结构:  com |-- x | |-- Alpha.class | | | |-- y | |-- Beta.class | |-- Gamma.class  和类:  class Test { Alpha a; Beta b; Gamma c; }  哪三个必须加入到类 Test 中,以使其通过编译?()

    • A、package y;
    • B、package com;
    • C、import com.x.*;
    • D、import com.x.y.*

    正确答案:B,C,D

  • 第16题:

    在Java语言中,在包Package1中包含包Package2,类Class_A直接隶属于包Package1,类Class_B直接隶属于包Package2,在类Class_C要应用Class_A的方法A和Class_B的方法B,你需要()语句。

    • A、import Package1.*;
    • B、import Package1.Package2.*;
    • C、import Package2.*;
    • D、import Package2.Package1.*;

    正确答案:A,B

  • 第17题:

    类Student的声明如下:   package com.school class Student{ String name;  int age;  Student(String name,int age){  //code } void study(String subject){ / /code } }  正确调用方法study(String subject)的是哪项?() 

    • A、Student stu = new Student(“Tom”,23); stu.study(“数学”);
    • B、Student.study(“数学”);
    • C、Student stu = new Student(“Tom”,23); stu.study();
    • D、Student stu = new Student(“Tom”,23); String result=stu.study(“数学”);

    正确答案:A

  • 第18题:

    package sun.scjp;  public enum Color { RED, GREEN, BLUE }  package sun.beta;  // insert code here  public class Beta {  Color g = GREEN;  public static void main( String[] argv)  { System.out.println( GREEN); }  }  The class Beta and the enum Color are in different packages.  Which two code fragments, inserted individually at line 2 of the Beta declaration, will allow this code to compile?()

    • A、 import sun.scjp.Color.*;
    • B、 import static sun.scjp.Color.*;
    • C、 import sun.scjp.Color; import static sun.scjp.Color.*;
    • D、 import sun.scjp.*; import static sun.scjp.Color.*;
    • E、 import sun.scjp.Color; import static sun.scjp.Color.GREEN;

    正确答案:C,E

  • 第19题:

    在类Acoount中,正确引入类school.Student的语句是哪一项?()  

    • A、import school
    • B、import schllo.*
    • C、package school.Student
    • D、import Student

    正确答案:B

  • 第20题:

    单选题
    在单一文件中import、class和package的正确出现顺序是()
    A

    package,import,class

    B

    class,import,package

    C

    import,package,class

    D

    package,class,import


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

  • 第21题:

    单选题
    在JSP中使用JDBC语句访问数据库,正确导入S QL类库的语句是()。
    A

    <%@ page import=”java.sql.*” %> 

    B

    <%@ page import=” sql.*” %> 

    C

    <%page import=”java.sql.*” %>  

    D

    <%@ import=”java.sql.*” %>


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

  • 第22题:

    单选题
    下列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或多个,接口定义。

  • 第23题:

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