A. import java.awt.*; package mypackage; class MyClass { } B. package mypackage; import java.awt.*; public class myClass { } C. int m; package mypackage; Import java.awt.*; class MyClass { } D. /*This is a comment*/ package mypackage; import java.awt.*; public class MyClass { }
举一反三
- 假定以下程序代码都分别放在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{}
- 下列哪个选项的java源文件代码片段是不正确的( )。 A: package mypackage; public class Test{ } B: import java.io.*; class Person{ } C: C. import java.io.*; package mypackage; public class Test{ } D: import java.io.*;import java.awt.*;public class Test{ }
- MyClass 类位于 MyPackage 包中,在它的方法 MyClassMethod( )中调用了类 OtherClass 中的 OtherClassMethod( )方法,OtherClass 类位于包 OtherPackage 中,下列代码正确的是( )。 A: import OtherPackage. * ; package MyPackage; public class MyClass{ public void MyClassMethod(){ OtherClassethod(); } } B: import OtherPackage. * ; public class MyClass{ public void MyClassMethod(){ OtherClassethod(); } } C: package MyPackage; public class MyClass{ public void MyClassMethod(){ OtherClassethod(); } } D: package MyPackage; import OtherPackage. * ; public class MyClass{ public void MyClassMethod(){ OtherClassethod(); } }
- 下面程序段中不正确的是( )。 A: package myPackage;public class A{} B: package myPackage; class B{ } C: package myPackage; import java.io.*; public class C{ } D: import java.awt.Color; package myPackage; class D{ }
- 下面哪个代码片段是错误的? A: package mypackage;public class Rectangle{//doing something…} B: import java.io.*;package mypackage;public class Rectangle{//doing something…} C: import java.io.*;class Circle{//doing something…}public class Rectangle{//doing something…} D: import java.io.*;import java.awt.*;public class Rectangle{//doing something…}
内容
- 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中,需要定义一个类叫MyClass,同时需要将类放到包package1中,正确的语句是: A: public class package1.MyClass { } B: public class MyClass {} in package1 C: package package1;public class MyClass{ } D: package package1;public class MyClass{ };
- 4
以下程序片段,下列哪个选项插入到第二行将引起编译错误?package mypackage;class MyClass{//do something} A: public class MainClass{} B: package mypackage1; C: class B{} D: Iimport java.util.*;