Question 61
class MCZ27 {
public static void main (String[] args) {
char a = '\f'; // 1
char b = '\n'; // 2
char c = '\r'; // 3
char d = '\l'; // 4
char e = '\\'; // 5
}}A compile-time error is generated at which line?
a. 1
b. 2
c. 3
d. 4
e. 5
f. None of the above
Question 62
class MCZ28 {
public static void main (String[] args) {
char a = '\b'; // 1
char b = '\d'; // 2
char c = '\f'; // 3
char d = '\t'; // 4
char e = '\"'; // 5
}}A compile-time error is generated at which line?
a. 1
b. 2
c. 3
d. 4
e. 5
f. None of the above
Question 63
class MCZ29 {
public static void main (String[] args) {
char a = '\a'; // 1
char b = '\b'; // 2
char c = '\f'; // 3
char d = '\n'; // 4
char e = '\r'; // 5
}}A compile-time error is generated at which line?
a. 1
b. 2
c. 3
d. 4
e. 5
f. None of the above
Question 64
class MCZ30 {
public static void main (String[] args) {
char a = '\t'; // 1
char b = '\\'; // 2
char c = '\?'; // 3
char d = '\"'; // 4
char e = '\''; // 5
}}A compile-time error is generated at which line?
a. 1
b. 2
c. 3
d. 4
e. 5
f. None of the above
Question 65
class MCZ31 {
public static void main (String[] args) {
char a = '\t'; // 1
char b = '\\'; // 2
char c = '\"'; // 3
char d = '\''; // 4
char e = '\?'; // 5
}}A compile-time error is generated at which line?
a. 1
b. 2
c. 3
d. 4
e. 5
f. None of the above
Question 66
class MCZ13 {
public static void main (String[] args) {
String s = null;
System.out.print(s);
}}What is the result of attempting to compile and run the program?
a. Prints nothing.
b. Prints: null
c. Compile-time error
d. Run-time error
e. None of the above
Question 67
class MCZ15 {
public static void main (String[] args) {
float a = 1.1e1f; // 1
float b = 1e-1F; // 2
float c = .1e1f; // 3
double d = .1d; // 4
double e = 1D; // 5
}}A compile-time error is generated at which line?
a. 1
b. 2
c. 3
d. 4
e. 5
f. None of the above
Question 68
class MCZ16 {
public static void main (String[] args) {
float a = 1; // 1
float b = 1L; // 2
float c = 1F; // 3
float d = 1.0; // 4
}}A compile-time error is generated at which line?
a. 1
b. 2
c. 3
d. 4
e. None of the above
Question 69
class MCZ17 {
public static void main (String[] args) {
String a = "\n"; // 1
String b = "\r"; // 2
String c = "\u000a"; // 3 \u000a = new line
String d = "\u000d"; // 4 \u000d = return
}}Compile-time errors are generated at which lines?
a. 1
b. 2
c. 3
d. 4
Question 70
class MCZ18 {
public static void main (String[] args) {
String a = "abcd"; // 1
String b = "'\u0041'"; // 2
String c = "\u0041"; // 3
String d = "\uD7AF"; // 4
System.out.print(a+b+c+d); // 5
}}A compile-time error is generated at which line?
a. 1
b. 2
c. 3
d. 4
e. 5
f. None of the above
Question 71
class MCZ20 {
public static void main (String[] args) {
// Insert code here.
}}Which of the following lines can be inserted at the specified location without generating a compile-time error?
a. String a = 'a';
b. String b = 'abc';
c. String c = '\u0041';
d. String d = '\uabcd';
e. None of the above
Question 72
class MCZ21 {
public static void main (String[] args) {
// Insert code here.
}}Which of the following lines can be inserted at the specified location without generating a compile-time error?
a. char a = a;
b. char b = abc;
c. char c = \u0041;
d. char d = \uabcd;
e. None of the above
Question 73
class MCZ24 {
public static void main (String[] args) {
char a = 061; // 1
char b = '\61'; // 2
char c = '\061'; // 3
char d = 0x0031; // 4
char e = '\u0031'; // 5
System.out.print(""+a+b+c+d+e);
}}A compile-time error is generated at which line?
a. 1
b. 2
c. 3
d. 4
e. 5
f. None of the above
Question 74
class MCZ25 {
public static void main (String[] args) {
char a = '\7'; // 1
char b = '\61'; // 2
char c = '\062'; // 3
char d = '\x7'; // 4
char e = '\x41'; // 5
System.out.print(""+a+b+c+d+e);
}}Compile-time errors are generated at which lines?
a. 1
b. 2
c. 3
d. 4
e. 5
Question 75
class MCZ19 {
public static void main (String[] args) {
String a1 = null; // 1
String b1 = 'null'; // 2
String c1 = "null"; // 3
String d1 = "'null'"; // 4
}}A compile-time error is generated at which line?
a. 1
b. 2
c. 3
d. 4
e. None of the above
Question 76
class MCZ22 {
public static void main (String[] args) {
// Insert code here.
}}Which of the following lines will generate a compile-time error if inserted at the specified location?
a. char a = 0x0041;
b. char b = '\u0041';
c. char c = 0101;
d. char d = -1;
e. char e = (char)-1;
f. None of the above
Question 77
class MCZ23 {
public static void main (String[] args) {
// Insert code here.
}}Which of the following lines can be inserted at the specified location without generating a compile-time error?
a. boolean b1 = true;
b. boolean b2 = TRUE;
c. boolean b3 = 'true';
d. boolean b4 = "TRUE";
e. boolean b5 = 0;
f. None of the above
61
|
d
|
4
|
The escape sequences are as follows: '\b' (backspace),
'\f' (formfeed), '\n' (newline), '\r' (carriage return), '\t' (horizontal
tab), '\\' (backslash), '\"' (double quote), '\'' (single quote). Yes,
you must memorize the escape sequences! Just remember "big farms need red
tractors".
|
62
|
b
|
2
|
The escape sequences are as follows: '\b' (backspace),
'\f' (formfeed), '\n' (newline), '\r' (carriage return), '\t' (horizontal
tab), '\\' (backslash), '\"' (double quote), '\'' (single quote). Yes, you
must memorize the escape sequences! Just remember "big farms need red tractors".
|
63
|
a
|
1
|
The escape sequences are as follows: '\b' (backspace),
'\f' (formfeed), '\n' (newline), '\r' (carriage return), '\t' (horizontal
tab), '\\' (backslash), '\"' (double quote), '\'' (single quote). Yes,
you must memorize the escape sequences! Just remember "big farms need red
tractors".
|
64
|
c
|
3
|
The escape sequences are as follows: '\b' (backspace),
'\f' (formfeed), '\n' (newline), '\r' (carriage return), '\t' (horizontal
tab), '\\' (backslash), '\"' (double quote), '\'' (single quote). Yes,
you must memorize the escape sequences! Just remember "big farms need red
tractors".
|
65
|
e
|
5
|
The escape sequences are as follows: '\b' (backspace),
'\f' (formfeed), '\n' (newline), '\r' (carriage return), '\t' (horizontal
tab), '\\' (backslash), '\"' (double quote), '\'' (single quote). Yes,
you must memorize the escape sequences! Just remember "big farms need red
tractors".
|
66
|
b
|
Prints: null
|
The System.out.print method prints the word null if the
argument is a String reference that is null.
|
67
|
f
|
None of the above
|
Floating-point literals are covered in section 3.10.2 of
the JLS. A floating-point literal can begin with either a digit or a decimal
point. Optionally, it can have a fractional part, an exponent part and a
floating point suffix--f, F, d, or D.
|
68
|
d
|
4
|
The literal 1.0 is a double and can not be used to
initialize a float without an explicit cast.
|
69
|
c d
|
3 4
|
The compiler interprets \u000a as a line terminator. The
escape sequence \n should be used instead. Similarly, \u000d is interpreted
as a line terminator. The escape sequence \r should be used instead.
|
70
|
f
|
None of the above
|
All of the declarations are legal. String b is a single
quote followed by the letter A followed by another single quote. String c is
the letter A. String d is the Unicode character that is represented by the
hexadecimal value D7AF. String literals are covered in section 3.10.5 of the
JLS.
|
71
|
e
|
None of the above
|
String literals are declared using double quotes, but all
of the declarations here use single quotes.
|
72
|
e
|
None of the above
|
Unicode char literals are declared using single quotes,
but none of the declarations here use single quotes. The declaration of char
b, is also problematic, because it contains more than one char.
|
73
|
f
|
None of the above
|
All of the declarations are legal. The first three ( 061, '\61',
'\061' ) are declared in octal format. The fourth (0x0031) is declared as a
hexadecimal literal. The fifth ('\u0031') is a Unicode escape sequence.
|
74
|
d e
|
4 5
|
All of the escape sequences used in this question are
defined for the C programming language. Those that are not also Java escape
sequences result in a compile-time error. Java does not accept the
hexadecimal escape sequences of the C programming language. However, Java
does accept Unicode escapes (JLS 3.3).
|
75
|
b
|
2
|
The reference a1 is set to null. String b1 generates a
compile-time error, because String literals must be enclosed by double
quotes. String c1 is the word null. String d1 is a single quote followed by
the word null followed by another single quote. String literals are covered
in section 3.10.5 of the JLS.
|
76
|
d
|
char d = -1;
|
The assignment of -1 to char d generates a compile-time
error, because the primitive char type is unsigned. A negative int can not be
assigned to a char without an explicit cast. If the literal value -1 were
cast to type char then the result would be \uffff.
|
77
|
a
|
boolean b1 = true;
|
There are two primitive boolean values: true and false.
Both must be written with lower case letters. Although the C programming
language accepts zero as a boolean value, the Java programming language does
not.
|
No comments:
Post a Comment