Java 面向对象的程序设计 第二周练习

成绩: 92分   最高成绩:96.0分   

一.单选题(共25题,100.0分)
1
2.2 Q5: Which command compiles the Java source code file Welcome.java?
A、 cd Welcome.java
B、 javac Welcome.java
C、 java Welcome.java
D、 compile Welcome.java
正确答案: B 我的答案:B 得分: 4.0分
2
2.3 Q4: Which of the following escape sequences represents a carriage return?
A、 \n.
B、 \r.
C、 \cr.
D、 \c.
正确答案: B 我的答案:B 得分: 4.0分
3
2.8 Q2: Which of the following is not a compilation error?
A、 Neglecting to initialize a local variable in a method before it is used.
B、 Placing a semicolon at the end of the first line of an if statement.
C、 Omitting the left and right parenthesis for the condition of an if statement.
D、 All are compilation errors.
正确答案: B 我的答案:D 得分: 0.0分
4
2.3 Q2: Which of the following is the escape character?
A、 *
B、
C、 \n
D、 "
正确答案: B 我的答案:B 得分: 4.0分
5
2.5.8 Q2:{ Given the Java statement sum = number1 + number2;which of the following statements is false?}
A、 It’s an assignment statement.
B、 It calculates the sum of variables number1 and number2.
C、 The operands of the addition operator are number1 and number2.
D、 It assigns the value of number1 to sum.
正确答案: D 我的答案:D 得分: 4.0分
6
2.5.6 Q2: {Given the Java statement number1 = input.nextInt();in which number1 is an int and input is a Scanner, which of the following occurs if the user does not enter a valid int value?}
A、 A compilation error occurs.
B、 The program continues executing and assigns the value 0 to number1.
C、 A runtime logic error occurs.
D、 None of the above.
正确答案: C 我的答案:D 得分: 0.0分
7
2.2 Q3: Which of the following cannot cause a syntax error to be reported by the Java compiler?
A、 Mismatched {}
B、 Missing / in a comment that begins with /
C、 Missing ;
D、 An extra blank line.
正确答案: D 我的答案:D 得分: 4.0分
8
2.4 Q2: Which of the following statement displays Hello World?
A、 System.out.printf( “%2s”, "Hello " “World” );
B、 System.out.printf( “%s %s”, “Hello”, “World” );
C、 System.out.printf( “%s%s”, “Hello, World” );
D、 System.out.printf( “s% s%”, “Hello”, “World” );
正确答案: B 我的答案:B 得分: 4.0分
9
2.3 Q5: Which of the following statements would display the phase Java is fun?
A、 System.out.println( "hellois fun\rJava " );
B、 System.out.println( ‘Java is fun’ );
C、 System.out.println( ““Java is fun”” );
D、 System.out.println( Java is fun );
正确答案: A 我的答案:A 得分: 4.0分
10
2.7 Q1: {What is the value of result after the following Java statements execute (assume all variables are of type int)?

a=4; b=12;

c=37;

d= 51

result = d % a * c + a % b + a; }

A、
119

B、
51

C、
127

D、
59

正确答案: A 我的答案:A 得分: 4.0分
11
2.2 Q6: Which command executes the Java class file Welcome.class?
A、 java welcome
B、 java Welcome.class
C、 java Welcome
D、 run Welcome.class
正确答案: C 我的答案:C 得分: 4.0分
12
2.5.3 Q2: A(n) ________ enables a program to read data from the user.
A、 printf.
B、 import declaration.
C、 Scanner.
D、 main.
正确答案: C 我的答案:C 得分: 4.0分
13
2.5.1 Q1: All import declarations must be placed
A、 inside the class declaration’s body.
B、 before the class declaration.
C、 after the class declaration.
D、 all of the above will work.
正确答案: B 我的答案:B 得分: 4.0分
14
2.2 Q2: Which of the following is not a valid Java identifier?
A、 my Value
B、 $_AAA1
C、 width
D、 m_x
正确答案: A 我的答案:A 得分: 4.0分
答案解析:

my Value (Identifiers may not contain blanks).
15
2.5.9 Q2: Optional parentheses in expressions are said to be
A、 redundant.
B、 binary operators.
C、 implied.
D、 declared.
正确答案: A 我的答案:A 得分: 4.0分
16
2.5.1 Q2: Java’s predefined classes are grouped into
A、 packets.
B、 declarations.
C、 Galleries.
D、 packages.
正确答案: D 我的答案:D 得分: 4.0分
17
2.5.2 Q1: The filename for the public class that begins with public class Addition must be
A、 public.java.
B、 public.class.java.
C、 Addition.java.
D、 addition.java.
正确答案: C 我的答案:C 得分: 4.0分
18
2.4 Q1: When method printf requires multiple arguments, the arguments are separated with ________.
A、 colons (😃.
B、 semicolons (😉.
C、 commas (,).
D、 periods (.).
正确答案: C 我的答案:C 得分: 4.0分
19
2.7 Q2: Which of the following is not an arithmetic operator?
A、 +
B、 -
C、 .
D、 %
正确答案: C 我的答案:C 得分: 4.0分
20
2.5.9 Q1: The format specifier ________ is a placeholder for an int value.
A、 %n
B、 %d
C、 %int
D、 %s
正确答案: B 我的答案:B 得分: 4.0分
21
2.6 Q1: Which of the following statements does not alter the value stored in a memory location?
A、 int a;
B、 number = 12;
C、 y = y + 2;
D、 width = Integer.parseInt(input);
正确答案: A 我的答案:A 得分: 4.0分
22
2.2 Q4: Which of the following does not contain a syntax error?
A、 System.out.println( ‘Hello world!’ ):
B、 System.out.println( “Hello 回车换行world!” );
C、 System.out.println( “Hello world!” );
D、 System.out.println( Hello world! );
正确答案: C 我的答案:C 得分: 4.0分
23
2.5.2 Q2 The body of each class declaration begins with ________ and ends with ________.
A、 (, ).
B、 [, ].
C、 {, }.
D、 /, .
正确答案: C 我的答案:C 得分: 4.0分
24
2.2 Q1: End-of-line comments that should be ignored by the compiler are denoted using

A、
Two forward slashes ( // ).

B、
Three forward slashes ( /// ).

C、
A slash and a star ( /* ).

D、
A slash and two stars ( /** ).

正确答案: A 我的答案:A 得分: 4.0分
25
2.5.8 Q1: Portions of statements that contain calculations are called
A、 variables.
B、 constants.
C、 expressions.
D、 None of the above.
正确答案: C 我的答案:C

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值