OCJP(Java 6) 기출문제 연습 17(161~170)
PC나 스마트폰에서도 동일하게 실행되므로 장소를 가리지 않고 OCJP(JAVA 6) 국제 자격증을 목표로 학습할 수 있다.
QUESTION 161
Given:
public void testIfA() {
if (testIfB("True")) { //Linea 12
System.out.println("True");
} else {
System.out.println("Not true");
}
}
public Boolean testIfB(String str) {
return Boolean.valueOf(str); //Linea 19
}
What is the result when method testIfA is invoked?
Given:
public void testIfA() {
if (testIfB("True")) { //Linea 12
System.out.println("True");
} else {
System.out.println("Not true");
}
}
public Boolean testIfB(String str) {
return Boolean.valueOf(str); //Linea 19
}
What is the result when method testIfA is invoked?
A
설명없음
QUESTION 162
Which can appropriately be thrown by a programmer using Java SE technology to create a desktop application?
Which can appropriately be thrown by a programmer using Java SE technology to create a desktop application?
D
설명없음
QUESTION 162
Which two code fragments are most likely to cause a StackOverflowError? (Choose two.)
Which two code fragments are most likely to cause a StackOverflowError? (Choose two.)
D,F
설명없음
QUESTION 164
Given:
public static void main(String[] args) {
Integer i = new Integer(1) + new Integer(2);
switch(i) {
case 3: System.out.println("three"); break;
default: System.out.println("other"); break;
}
}
What is the result?
Given:
public static void main(String[] args) {
Integer i = new Integer(1) + new Integer(2);
switch(i) {
case 3: System.out.println("three"); break;
default: System.out.println("other"); break;
}
}
What is the result?
A
설명없음
QUESTION 165
Given:
public class Tahiti {
Tahiti t;
public static void main(String[] args) {
Tahiti t = new Tahiti();
Tahiti t2 = t.go(t);
t2 = null;
// more code here 11
}
Tahiti go(Tahiti t) {
Tahiti t1 = new Tahiti();
Tahiti t2 = new Tahiti();
t1.t = t2;
t2.t = t1;
t.t = t2;
return t1;
}
}
When line 11 is reached, how many objects are eligible for garbage collection?
Given:
public class Tahiti {
Tahiti t;
public static void main(String[] args) {
Tahiti t = new Tahiti();
Tahiti t2 = t.go(t);
t2 = null;
// more code here 11
}
Tahiti go(Tahiti t) {
Tahiti t1 = new Tahiti();
Tahiti t2 = new Tahiti();
t1.t = t2;
t2.t = t1;
t.t = t2;
return t1;
}
}
When line 11 is reached, how many objects are eligible for garbage collection?
A
설명없음
QUESTION 165
Given:
public class Commander {
public static void main(String[] args) {
String myProp = /* insert code here Linea 13 */
System.out.println(myProp);
}
}
and the command line: java -Dprop.custom=gobstopper Commander
Which two, placed on line 13, will produce the output gobstopper? (Choose two.)
Given:
public class Commander {
public static void main(String[] args) {
String myProp = /* insert code here Linea 13 */
System.out.println(myProp);
}
}
and the command line: java -Dprop.custom=gobstopper Commander
Which two, placed on line 13, will produce the output gobstopper? (Choose two.)
D,E
설명없음
QUESTION 167
Given:
public class ItemTest {
private final int id;
public ItemTest(int id) {
this.id = id;
}
public void updateId(int newId) {
id = newId;
}
public static void main(String[] args) {
ItemTest fa = new ItemTest(42);
fa.updateId(69);
System.out.println(fa.id);
}
}
What is the result?
Given:
public class ItemTest {
private final int id;
public ItemTest(int id) {
this.id = id;
}
public void updateId(int newId) {
id = newId;
}
public static void main(String[] args) {
ItemTest fa = new ItemTest(42);
fa.updateId(69);
System.out.println(fa.id);
}
}
What is the result?
A
The final field ItemTest.id cannot be assigned
QUESTION 167
A developer is creating a class Book, that needs to access class Paper.
The Paper class is deployed in a JAR named myLib.jar.
Which three, taken independently, will allow the developer to use the Paper class while compiling the Book class? (Choose three.)
A developer is creating a class Book, that needs to access class Paper.
The Paper class is deployed in a JAR named myLib.jar.
Which three, taken independently, will allow the developer to use the Paper class while compiling the Book class? (Choose three.)
B,D,G
설명없음
QUESTION 169
Given:
public class Yippee {
public static void main(String[] args) {
for (int x = 1; x < args.length; x++) {
System.out.print(args[x] + " ");
}
}
}
and two separate command line invocations: java Yippee java Yippee 1 2 3 4
What is the result?
Given:
public class Yippee {
public static void main(String[] args) {
for (int x = 1; x < args.length; x++) {
System.out.print(args[x] + " ");
}
}
}
and two separate command line invocations: java Yippee java Yippee 1 2 3 4
What is the result?
B
설명없음
QUESTION 170
Click the Exhibit button.
class Foo {
private int x;
public Foo( int x ){ this.x = x;}
public void setX( int x ) { this.x = x; }
public int getX(){ return x;}
}
public class Gamma {
static Foo fooBar(Foo foo) {
foo = new Foo(100);
return foo;
}
public static void main(String[] args) {
Foo foo = new Foo( 300 );
System.out.println( foo.getX() + "-");
Foo fooFoo = fooBar(foo);
System.out.println(foo.getX() + "-");
System.out.println(fooFoo.getX() + "-");
foo = fooBar( fooFoo);
System.out.println( foo.getX() + "-");
System.out.println(fooFoo.getX());
}
}
What is the output of the program shown in the exhibit?
Click the Exhibit button.
class Foo {
private int x;
public Foo( int x ){ this.x = x;}
public void setX( int x ) { this.x = x; }
public int getX(){ return x;}
}
public class Gamma {
static Foo fooBar(Foo foo) {
foo = new Foo(100);
return foo;
}
public static void main(String[] args) {
Foo foo = new Foo( 300 );
System.out.println( foo.getX() + "-");
Foo fooFoo = fooBar(foo);
System.out.println(foo.getX() + "-");
System.out.println(fooFoo.getX() + "-");
foo = fooBar( fooFoo);
System.out.println( foo.getX() + "-");
System.out.println(fooFoo.getX());
}
}
What is the output of the program shown in the exhibit?
B
설명없음