目录
清览题库1
1. 给出下列【代码】注释标注的代码的输出结果。
public class Example
{
public static void main(String args[])
{
System.out.println("hello"); //【代码】
}
}
答案
hello
2. 给出下列【代码】注释标注的代码的输出结果。
public class E
{
public static void main(String args[])
{
System.out.println(100); //【代码】
}
}
答案
100
3. Java语言的主要贡献者是James Gosling。
答案
是
4. Java语言是1995年5月Sun公司推出的编程语言
答案
是
5. 开发Java应用程序的基本步骤是:
1 编写源文件,
2.编译源文件,
3.运行程序。
答案
是
6. Java源文件是由若干个书写形式互相独立的类组成。
答案
是
7. Java源文件中只能有一个类。
答案
否
8. 如果源文件中有多个类,那么至多有一个类可以是public类
答案
是
9. java源文件的扩展名是.java
答案
是
10. 编译java源文件得到的字节码文件的扩展名是.class
答案
是
11. 下列源文件可保存成dog.java
public class Dog
{
public void cry()
{
System.out.println("wangwang");
}
}
答案
否
12. 下列源文件可以保存成Dog.java或Cat.java
class Dog
{
public void cry()
{
System.out.println("wangwang");
}
}
class Cat
{
public void cry()
{
System.out.println("maiomiao");
}
}
答案
是
13. java编译器的名字是java.exe
答案
否
14. 下列源文件People.java中People是主类
class Hello
{
public void speak()
{
System.out.println("wangwang");
}
}
public class People
{
public static void main(String args[])
{
System.out.println("你好");
}
}
答案
是
15. 下列源文件Hello.java的编程风格属于行尾风格
public class Hello {
public void speak() {
System.out.println("wangwang");
}
}
class People {
public static void main(String args[]) {
System.out.println("你好");
}
}
答案
是
16. 编译下列源文件的Person.java将得到2个字节码文件: Person.class和Xiti.class.
public class Person
{
void speakHello()
{
System.out.print("您好,很高兴认识您");
System.out.println(" nice to meet you");
}
}
class Xiti
{
public static void main(String args[])
{
Person zhang = new Person();
zhang.speakHello();
}
}
答案
是
17. 下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?
public class Example //【1】
{
public static void main(String args[]) //【2】
{
System.out.println("ok"); //【3】
System.out.println("hello");
system.out.println("您好"); //【4】
}
}
A. 1
B. 2
C. 3
D. 4
答案
D
18. 下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?
Public class Example //【1】
{
public static void main(String args[]) //【2】
{
System.out.println("ok"); //【3】
System.out.println("hello");
System.out.println("您好"); //【4】
}
}
A. 1
B. 2
C. 3
D. 4
答案
A
19. 下列【1】、【2】、【3】、【4】注释标注的哪行代码有错误?
public class Example //【1】
{
public static void main(string args[]) //【2】
{
System.out.println("ok"); //【3】
System.out.println("hello");
System.out.println("您好"); //【4】
}
}
A. 1
B. 2
C. 3
D. 4
答案
B
20. 阅读下列Java源文件,并回答问题。
public class Speak
{
void speakHello()
{
System.out.println("I'm glad to meet you");
}
}
class Xiti4
{
public static void main(String args[])
{
Speak sp=new Speak();
sp.speakHello();
}
}
(1) 上述源文件的名字是什么?
(2) 上述源文件编译后生成几个字节码文件?
这些字节码文件的名字都是什么?
(3) 使用Java解释器运行哪个字节码文件?
(4) 在命令行执行java Speak 得到怎样的错误提示?
答案
1)Speak.java
2)2个字节码文件。Speak.class ,Xiti4.class
3) Xiti4
4) 错误: 在类 Speak 中找不到 main 方法
清览题库2
1. 给出下列【代码】注释标注的代码的输出结果。
public class E
{
public static void main(String args[])
{
int m = 100;
System.out.println(m+"100"); //【代码】
}
}
答案
100100
2. 给出下列【代码】注释标注的代码的输出结果。
public class E
{
public static void main(String args[])
{
int a[] = {1,2,3,4};
int b[] = {100,200,300};
b = a;
System.out.println(b[3]); //【代码】
}
}
答案
4
3. 标识符的第一个字符可以是数字。
答案
否
4. Bird和bird是相同的标识符。
答案
否
5. 3.14是float型常量。
答案
否
6. 3.14和0.618d都是double型常量。
答案
是
7. 2e5和3.14E2都是double型常量.
答案
是
8. int []a;和int a[];都是正确的声明了一个一维数组a。
答案
是
9. int a[],b;
是声明了一个int型一维数组a和一个int型变量b。
答案
是
10. float a[20];是错误的数组声明。
答案
是
11. boolean yes = TRUE;是正确的boolean变量声明。
答案
否
12. float area = 1e1;是错误的float变量声明。
答案
是
13. char ch = '\\';是正确的char变量声明。
答案
是
14. char ch = 97;是错误的char变量声明。