5. (单选题)Outer类中定义了一个成员内部类Inner,需要在main()方法中创建Inner类实例对象,以下四种方式哪一种是正确的?( )
A. Inner in = new Inner()
B. Inner in = new Outer.Inner();
C. Outer.Inner in = new Outer.Inner();
D. Outer.Inner in = new Outer().new Inner();
https://www.shititong.cn/cha-kan/shiti/0005e1b3-7b7a-56a0-c04c-ee30166b1a00.html
点击查看答案
4. (单选题)
设有右边两个类的定义,类Shape和类Rectangle的关系是什么?
class Shape
{ … }
class Rectangle extends Shape
{ … }
A. 包含关系
B. 继承关系
C. 关联关系
D. 无关系,类定义有语法错误
https://www.shititong.cn/cha-kan/shiti/0005e1b4-86b7-9798-c04c-ee30166b1a00.html
点击查看答案
20. (单选题)下列说法正确的是( )
A. 一个程序可以包含多个源文件
B. 一个源文件中只能有一个类
C. 一个源文件中可以有多个公共类
D. 一个源文件只能供一个程序使用
https://www.shititong.cn/cha-kan/shiti/0005e1b3-7b7a-75e0-c04c-ee30166b1a00.html
点击查看答案
9. (单选题)
分析下面程序,输出结果是( )。
public class Test {
public static void main( ) {
String s1=new String( );
String s2="true";
if(s1==s2) //第5行
System.out.print( );
else System.out.print( );
}
}
A. Equal
B. No Equal
C. 程序运行时产生异常
D. 第5行编译出错
https://www.shititong.cn/cha-kan/shiti/0005e1b3-7b7a-5a88-c04c-ee30166b1a02.html
点击查看答案
7. (判断题)类中static修饰的变量或方法,可以使用类名或对象的引用变量访问。
https://www.shititong.cn/cha-kan/shiti/0005e1b3-7b7a-4700-c04c-ee30166b1a01.html
点击查看答案
8. (判断题)方法内部类中不能访问外部类的成员变量。
https://www.shititong.cn/cha-kan/shiti/0005e1b3-7b7a-4700-c04c-ee30166b1a02.html
点击查看答案
4. (填空题)若int []a={12,45,34,46,23}; ,则a[2]= ______。
https://www.shititong.cn/cha-kan/shiti/0005e1b3-7b7a-3760-c04c-ee30166b1a01.html
点击查看答案
9. (单选题)安装好JDK后,在其bin目录下有许多exe可执行文件,其中java.exe命令的作用是以下哪一种?( )
A. Java文档制作工具
B. Java解释器
C. Java编译器
D. Java启动器
https://www.shititong.cn/cha-kan/shiti/0005e1b3-7b79-e170-c04c-ee30166b1a02.html
点击查看答案
6. (判断题)Java中的每个类都至少有一个构造方法,一个类中如果没有定义构造方法,系统会自动为这个类创建一个默认的构造方法。
https://www.shititong.cn/cha-kan/shiti/0005e1b3-7b7a-4700-c04c-ee30166b1a00.html
点击查看答案
1. (单选题)Java应用程序中main()方法的声明格式可以是( )。
A. public static int main(String args[])
B. public static void main(String args[])
C. public void main(String args[])
D. public int main(String args[])
https://www.shititong.cn/cha-kan/shiti/0005e1b3-7b79-d5b8-c04c-ee30166b1a00.html
点击查看答案