Ensurepass.com : Ensure you pass the IT Exams
2018 Jan Oracle Official New Released 1z0-854
100% Free Download! 100% Pass Guaranteed!
http://www.EnsurePass.com/1z0-854.html
Java Standard Edition 5 Programmer Certified Professional Upgrade Exam
Question No: 81
Given:
-
class Super {
-
private int a;
-
protected Super(int a) { this.a = a; } 4. }
…
-
class Sub extends Super {
-
public Sub(int a) { super(a); }
-
public Sub() { this.a = 5; }
14. }
Which two, independently, will allow Sub to compile? (Choose two.)
-
Change line 2 to: protected int a;
-
Change line 13 to: public Sub() { super(a); }
-
Change line 13 to: public Sub() { this(5); }
-
Change line 2 to:
public int a;
-
Change line 13 to: public Sub() { super(5); }
Answer: C,E
Question No: 82
Given a pre-generics implementation of a method:
-
public static int sum(List list) {
-
int sum = 0;
-
for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
-
int i = ((Integer)iter.next()).intValue();
-
sum = i;
16. }
17. return sum;
18. }
Which three changes must be made to the method sum to use generics? (Choose three.)
-
replace line 14 with quot;int i = iter.next();quot;
-
replace line 13 with quot;for (Iterator iter : intList) {quot;
-
replace the method declaration with quot;sum(Listlt;intgt; intList)quot;
-
remove line 14
-
replace the method declaration with quot;sum(Listlt;Integergt; intList)quot;
-
replace line 13 with quot;for (int i : intList) {quot;
Answer: D,E,F
Question No: 83
Given:
-
double input = 314159.26;
-
NumberFormat nf = NumberFormat.getInstance(Locale.ITALIAN);
-
String b;
-
//insert code here
Which code, inserted at line 14, sets the value of b to 314.159,26?
-
b = nf.parse( input );
-
b = nf.equals( input );
-
b = nf.parseObject( input );
-
b = nf.format( input );
Answer: D
Question No: 84
Given:
-
String test = quot;a1b2c3quot;;
-
String[] tokens = test.split(quot;\\\\dquot;);
-
for(String s: tokens) System.out.print(s quot; quot;); What is the result?
A. a1b2c3
B. 1 2 3
-
a b c
-
An exception is thrown at runtime.
-
The code runs with no output.
-
a1 b2 c3
-
Compilation fails.
Answer: C
Question No: 85
Assuming that the serializeBanana() and the deserializeBanana() methods will correctly use Java serialization and given:
-
import java.io.*;
-
class Food implements Serializable {int good = 3;}
-
class Fruit extends Food {int juice = 5;}
-
public class Banana extends Fruit {
-
int yellow = 4;
-
public static void main(String [] args) {
-
Banana b = new Banana(); Banana b2 = new Banana();
-
b.serializeBanana(b); // assume correct serialization
-
b2 = b.deserializeBanana(); // assume correct
-
System.out.println(quot;restore quot; b2.yellow b2.juice b2.good);
24. }
25. // more Banana methods go here 50. } What is the result?
-
restore 453
-
Compilation fails.
-
An exception is thrown at runtime.
-
restore 400
-
restore 403
Answer: A
Question No: 86
Click the Exhibit button.
Which three statements are true? (Choose three.)
-
Compilation fails.
-
The code compiles and the output is 2.
-
If lines 16, 17 and 18 were removed, compilation would fail.
-
If lines 24, 25 and 26 were removed, compilation would fail.
-
If lines 16, 17 and 18 were removed, the code would compile and the output would be 2.
-
If lines 24, 25 and 26 were removed, the code would compile and the output would be 1.
Answer: B,E,F
Question No: 87 DRAG DROP
Click the Task button.
Answer:
Question No: 88 DRAG DROP
Click the Task button.
Answer:
Question No: 89
A UNIX user named Bob wants to replace his chess program with a new one, but he is not sure where the old one is installed. Bob is currently able to run a Java chess program starting from his home directory /home/bob using the command:
java -classpath /test:/home/bob/downloads/*.jar games.Chess Bob#39;s CLASSPATH is set (at login time) to:
/usr/lib:/home/bob/classes:/opt/java/lib:/opt/java/lib/*.jar What is a possible location for the Chess.class file?
-
/usr/lib/games/Chess.class
-
/home/bob/games/Chess.class
-
/home/bob/Chess.class
-
/test/Chess.class
-
inside jarfile /opt/java/lib/Games.jar (with a correct manifest)
-
/test/games/Chess.class
-
inside jarfile /home/bob/downloads/Games.jar (with a correct manifest)
Answer: F
Question No: 90
Given:
-
package com.company.application; 2.
-
-
public class MainClass {
-
public static void main(String[] args) {} 5. }
And MainClass exists in the /apps/com/company/application directory. Assume the CLASSPATH environment variable is set to quot;.quot; (current directory).
Which two java commands entered at the command line will run MainClass? (Choose two.)
-
java com.company.application.MainClass if run from the /apps/com/company/application directory
-
java -classpath . MainClass if run from the /apps/com/company/application directory
-
java MainClass if run from the /apps directory
-
java -classpath /apps/com/company/application:. MainClass if run from the /apps directory
-
java -classpath /apps com.company.application.MainClass if run from any directory
-
java com.company.application.MainClass if run from the /apps directory
-
Answer: E,F