OCJP(Java 6) 기출문제 연습 18(171~180)
PC나 스마트폰에서도 동일하게 실행되므로 장소를 가리지 않고 OCJP(JAVA 6) 국제 자격증을 목표로 학습할 수 있다.
QUESTION 171
Given classes defined in two different files:
1. package packageA;
2. public class Message {
3. String getText() {
4. return "text";
5. }
6. }
And:
1. package packageB;
2.
3. public class XMLMessage extends packageA.Message {
4. String getText() {
5. return "<msg>text</msg>";
6. }
7.
8. public static void main(String[] args) {
9. System.out.println(new XMLMessage().getText());
10. }
11.}
What is the result of executing XMLMessage.main?
Given classes defined in two different files:
1. package packageA;
2. public class Message {
3. String getText() {
4. return "text";
5. }
6. }
And:
1. package packageB;
2.
3. public class XMLMessage extends packageA.Message {
4. String getText() {
5. return "<msg>text</msg>";
6. }
7.
8. public static void main(String[] args) {
9. System.out.println(new XMLMessage().getText());
10. }
11.}
What is the result of executing XMLMessage.main?
C
설명없음
QUESTION 172
Given:
interface Fish {
}
class Perch implements Fish {
}
class Walleye extends Perch {
}
class Bluegill {
}
public class Fisherman {
public static void main(String[] args) {
Fish f = new Walleye();
Walleye w = new Walleye();
Bluegill b = new Bluegill();
if (f instanceof Perch)
System.out.print("f-p ");
if (w instanceof Fish)
System.out.print("w-f ");
if (b instanceof Fish)
System.out.print("b-f ");
}
}
What is the result?
Given:
interface Fish {
}
class Perch implements Fish {
}
class Walleye extends Perch {
}
class Bluegill {
}
public class Fisherman {
public static void main(String[] args) {
Fish f = new Walleye();
Walleye w = new Walleye();
Bluegill b = new Bluegill();
if (f instanceof Perch)
System.out.print("f-p ");
if (w instanceof Fish)
System.out.print("w-f ");
if (b instanceof Fish)
System.out.print("b-f ");
}
}
What is the result?
B
설명없음
QUESTION 173
Given:
1. package com.company.application;
2.
3. public class MainClass {
4. public static void main(String[] args) {
5. }
6. }
And MainClass exists in the /apps/com/company/application directory.
Assume the CLASSPATH environment variable is set to "." (current directory).
Which two java commands entered at the command line will run MainClass? (Choose two.)
Given:
1. package com.company.application;
2.
3. public class MainClass {
4. public static void main(String[] args) {
5. }
6. }
And MainClass exists in the /apps/com/company/application directory.
Assume the CLASSPATH environment variable is set to "." (current directory).
Which two java commands entered at the command line will run MainClass? (Choose two.)
B,C
설명없음
QUESTION 174
Given
class Foo {
static void alpha() {
/* more code here */
}
void beta() {
/* more code here */
}
}
Which two statements are true? (Choose two.)
Given
class Foo {
static void alpha() {
/* more code here */
}
void beta() {
/* more code here */
}
}
Which two statements are true? (Choose two.)
B,C
설명없음
QUESTION 175
Given:
1. public class TestSeven extends Thread {
2. private static int x;
3. public synchronized void doThings() {
4. int current = x;
5. current++;
6. x = current;
7. }
8. public void run() {
9. doThings();
10. }
11.}
Which statement is true?
Given:
1. public class TestSeven extends Thread {
2. private static int x;
3. public synchronized void doThings() {
4. int current = x;
5. current++;
6. x = current;
7. }
8. public void run() {
9. doThings();
10. }
11.}
Which statement is true?
E
설명없음
QUESTION 176
Given that the current directory is empty, and that the user has read and write privileges to the current directory, and the following:
1. import java.io.*;
2. public class Maker {
3. public static void main(String[] args) {
4. File dir = new File("dir");
5. File f = new File(dir, "f");
6. }
7. }
Which statement is true?
Given that the current directory is empty, and that the user has read and write privileges to the current directory, and the following:
1. import java.io.*;
2. public class Maker {
3. public static void main(String[] args) {
4. File dir = new File("dir");
5. File f = new File(dir, "f");
6. }
7. }
Which statement is true?
B
설명없음
QUESTION 177
Given:
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(4);
nf.setMinimumFractionDigits(2);
String a = nf.format(3.1415926);
String b = nf.format(2);
Which two statements are true about the result if the default locale is Locale.US? (Choose two.)
Given:
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(4);
nf.setMinimumFractionDigits(2);
String a = nf.format(3.1415926);
String b = nf.format(2);
Which two statements are true about the result if the default locale is Locale.US? (Choose two.)
C,F
설명없음
QUESTION 178
Which three statements concerning the use of the java.io.Serializable interface are true? (Choose three.)
Which three statements concerning the use of the java.io.Serializable interface are true? (Choose three.)
B,D,E
설명없음
QUESTION 179
Given:
12. String csv = "Sue,5,true,3";
13. Scanner scanner = new Scanner( csv );
14. scanner.useDelimiter(",");
15. int age = scanner.nextInt();
What is the result?
Given:
12. String csv = "Sue,5,true,3";
13. Scanner scanner = new Scanner( csv );
14. scanner.useDelimiter(",");
15. int age = scanner.nextInt();
What is the result?
D
설명없음
QUESTION 180
Given that c is a reference to a valid java.io.Console object, which two code fragments read a line of text from the console? (Choose two.)
Given that c is a reference to a valid java.io.Console object, which two code fragments read a line of text from the console? (Choose two.)
A,E
설명없음