【含答案】第二章 类与对象--2.2-4-包
(1)单选题
下列选项中,用于声明包名的关键字是:
A import
B package
C interface
D protected
(2)单选题
下列选项中,用于引入其他包的关键字是:
A import
B package
C infterface
D protected
(3)单选题
以下程序片段,下列哪个选项插入到第2行将引起编译错误:
1. package mypackage;
2.
3. class Myclass{
4. //do something
5. }
A public class MainClass{}
B package mypackage1;
C class B{}
D import java.util. *;
(4)单选题
下面哪个代码片段是错误的:
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...}