Part I Single Selection (2 score per question)
1. Which statement is true?( )
public void test(int x) {
int odd = 1;
if (odd) {
System.out.println("odd");
} else {
System.out.println("even");
}
}
(A) "odd" will always be output.
(B) "even" will always be output.
(C) Compilation fails.
(D) "odd" will be output for odd values of x, and "even" for even values.
2. Which one is not valid IP address ?
(A) 192.168.0.254 (B) 192.168.0.255 (C) 192.168.255.254 (D) 192.168.0.256
3. Select the one correct answer. The number of characters in an object of a class String is given by( )
(A) The member variable called size.
(B) The member variable called length
(C) The method size() returns the number of characters.
(D) The method length() returns the number of characters.
4. Which code determines the int value data closer to, but not greater than, a double value b? ( )
(A) Int data = (int) Math.floor(b);
(B) Int data = (int) Math.abs(b);
(C) Int data = (int) Math.ceil(b);
(D) Int data = (int) Math.min(b);
5. Linux file permission setting is presented by one string which length is 10,
it can be divided into 4 parts from left to right, So what is the meaning of the part 3 ?
Such as "drwxrwxr-x" => part1:"d", part2:"rwx", part3:"rwx", part4:"r-x"
(A) file type (B) permissions of file owner (C) permissions of file owner's group (D) permissions of other users
6. What will be the output of the program? ( )
public class X {
public static void main(String[] args) {
try {
badMethod();
System.out.print("A");
} catch (RuntimeException ex) {
System.out.print("B");
} catch (Exception ex1) {
System.out.print("C");
} finally {
System.out.print("D");
}
1. Which statement is true?( )
public void test(int x) {
int odd = 1;
if (odd) {
System.out.println("odd");
} else {
System.out.println("even");
}
}
(A) "odd" will always be output.
(B) "even" will always be output.
(C) Compilation fails.
(D) "odd" will be output for odd values of x, and "even" for even values.
2. Which one is not valid IP address ?
(A) 192.168.0.254 (B) 192.168.0.255 (C) 192.168.255.254 (D) 192.168.0.256
3. Select the one correct answer. The number of characters in an object of a class String is given by( )
(A) The member variable called size.
(B) The member variable called length
(C) The method size() returns the number of characters.
(D) The method length() returns the number of characters.
4. Which code determines the int value data closer to, but not greater than, a double value b? ( )
(A) Int data = (int) Math.floor(b);
(B) Int data = (int) Math.abs(b);
(C) Int data = (int) Math.ceil(b);
(D) Int data = (int) Math.min(b);
5. Linux file permission setting is presented by one string which length is 10,
it can be divided into 4 parts from left to right, So what is the meaning of the part 3 ?
Such as "drwxrwxr-x" => part1:"d", part2:"rwx", part3:"rwx", part4:"r-x"
(A) file type (B) permissions of file owner (C) permissions of file owner's group (D) permissions of other users
6. What will be the output of the program? ( )
public class X {
public static void main(String[] args) {
try {
badMethod();
System.out.print("A");
} catch (RuntimeException ex) {
System.out.print("B");
} catch (Exception ex1) {
System.out.print("C");
} finally {
System.out.print("D");
}
System.out.print("E");
}
public static void badMethod() {
throw new RuntimeException();
}
}
(A) BD
(B) BCD
(C) B
(D) BDE
7. What is valid returnType for getData? ( )
public class ReturnData {
<returnType> getData(byte a, double z) {
return (a / z) * 10;
}
}
(A) short (B) byte (C) int (D) double
8. What is the result? ( )
public static void mai