• 2022-07-23
    假定以下程序代码都分别放在MyClass.java文件中,哪些程序代码能够编译通过?
    A: import java.awt.*;package myPackage;class MyClass {}
    B: package myPackage;import java.awt.*;class MyClass{}
    C: /*This is a comment */package myPackage;import java.awt.*;public class MyClass{}
    D: /*This is a comment */package myPackage;import java.awt.*;public class OtherClass{}
  • B,C

    举一反三

    内容

    • 0

      下列Java源文件代码片段中,( )是正确的。 A: package t;public class A{} B: import java.io.*;package t;public class A{} C: import java.io.*;class A{}public class B{} D: import java.io.*;import java.awt.*;public class A{}

    • 1

      下面哪些代码段是正确的Java源程序? A: package testpackage; public class Test{//do something...} B: import java.io.*; package testpackage; public class Test{// do something...} C: import java.io.*; class Person{// do something...} public class Test{// do something...} D: import java.io.*; import java.awt.*; public class Test{// do something...}

    • 2

      下面哪些代码段是正确的Java源程序?( ) A: import java.io.*; package testpackage; public class Test{/* do something... */} B: import java.io.*;class Person{/* do something... */}public class Test{/* do something... */} C: import java.io.*; import java.awt.*; public class Test{/* do something... */} D: package testpackage;public class Test{/* do something... */}

    • 3

      Java中,在单一文件中import、class 和package的正确出现顺序是() A: class, import, package B: package, import, class C: import, package, class D: package, class, import

    • 4

      在一个Java源文件中,import,class,package语句的顺序是( )。 A: package import class B: import class package C: class import package D: package class import