[Free] 2018(Jan) EnsurePass Testinsides Oracle 1z0-808 Dumps with VCE and PDF 1-10

By | January 25, 2018

Ensurepass.com : Ensure you pass the IT Exams
2018 Jan Oracle Official New Released 1z0-808
100% Free Download! 100% Pass Guaranteed!
http://www.EnsurePass.com/1z0-808.html

Java SE 8 Programmer I

Question No: 1

Given the code fragment:

public class Test {

public static void main(String[] args) { boolean isChecked = false;

int arry[] = {1,3,5,7,8,9};

int index = arry.length; while ( lt;code1gt; ) {

if (arry[index-1] % 2 ==0) { isChecked = true;

}

lt;code2gt;

}

System.out.print(arry(index] quot;, quot; isChecked));

}

}

Which set of changes enable the code to print 1, true?

  1. Replacing lt;code1gt; with index gt; 0 and replacing lt;code2gt; with index-;

  2. Replacing lt;code1gt; with index gt; 0 and replacing lt;code2gt; with -index;

  3. Replacing lt;code1gt; with index gt; 5 and replacing lt;code2gt; with -index ;

  4. Replacing lt;code1gt; with index and replacing lt;code2gt; with -index ;

Answer: A Explanation:

Note: Code in B (code2 is -index;). also works fine.

Question No: 2

Given:

Ensurepass 2018 PDF and VCE

What is the result?

Ensurepass 2018 PDF and VCE

  1. Option A

  2. Option B

  3. Option C

  4. Option D

Answer: D

Question No: 3

Given:

Ensurepass 2018 PDF and VCE

What is the output?

A. 1Z0

B. 1Z0-808

  1. An exception will be thrown.

  2. Compilation fails due to error at line 3.

  3. Compilation tails due to error at line 4.

Answer: E Explanation:

Option E is the correct answer.

Code fails to compile because there is no method called concert in StringBuilder class. The concert method is in String class. Hence option E is correct Here we should have used append method of StringBuilder class, in that case option B would be correct. https://docs.oracle.com/javase/tutorial/java/data/buffers.html

Question No: 4

Given:

public class String1 {

public static void main(String[] args) { String s = quot;123quot;;

if (s.length() gt;2)

s.concat(quot;456quot;);

for(int x = 0; x lt;3; x ) s = quot;xquot;;

System.out.println(s);

}

}

What is the result?

A. 123

B. 123xxx

C. 123456

D. 123456xxx

E. Compilation fails

Answer: B Explanation: 123xxx

The if clause is not applied.

Note: Syntax of if-statement: if ( Statement ) {

}

Question No: 5

Given the code fragment:

Ensurepass 2018 PDF and VCE

What is the result?

  1. Sum is 600

  2. Compilation fails at line n1.

  3. Compilation fails at line n2.

  4. A ClassCastException is thrown at line n1.

  5. A ClassCastException is thrown at line n2.

Answer: C

Question No: 6

Given:

public class ComputeSum { public int x;

public int y; public int sum;

public ComputeSum (int nx, int ny) { x = nx; y =ny;

updateSum();

}

public void setX(int nx) { x = nx; updateSum();} public void setY(int ny) { x = ny; updateSum();} void updateSum() { sum = x y;}

}

This class needs to protect an invariant on the sum field.

Which three members must have the private access modifier to ensure that this invariant is maintained?

  1. The x field

  2. The y field

  3. The sum field

  4. The ComputerSum ( ) constructor

  5. The setX ( ) method

  6. The setY ( ) method

Answer: C,E,F

Explanation: The sum field and the two methods (setX and SetY) that updates the sum field.

Question No: 7

Given the code fragment:

Ensurepass 2018 PDF and VCE

What is the result if the integer aVar is 9?

  1. 10 Hello World!

  2. Hello Universe!

  3. Hello World!

  4. Compilation fails.

Answer: A

Question No: 8

Which statement will empty the contents of a StringBuilder variable named sb?

  1. sb.deleteAll();

  2. sb.delete(0, sb.size());

  3. sb.delete(0, sb.length());

  4. sb.removeAll();

Answer: C

Question No: 9

Given:

class Base {

// insert code here

}

public class Derived extends Base{ public static void main(String[] args) { Derived obj = new Derived(); obj.setNum(3);

System.out.println(quot;Square = quot; obj.getNum() * obj.getNum());

}

}

Which two options, when inserted independently inside class Base, ensure that the class is being properly encapsulated and allow the program to execute and print the square of the number?

  1. private int num; public int getNum() { return num; }public void setNum(int num) { this.num = num;}

  2. public int num; protected public int getNum() { return num; }protected public void setNum(int num) { this.num = num;}

  3. private int num;public int getNum() {return num;} private void setNum(int num) { this.num = num;}

  4. protected int num; public int getNum() { return num; } public void setNum(int num) { this.num = num;}

  5. protected int num; private int getNum() { return num; } public void setNum(int num) { this.num = num;}

Answer: A,D Explanation: Incorrect:

Not B: illegal combination of modifiers: protected and public not C: setNum method cannot be private.

not E: getNum method cannot be private.

Question No: 10

Which two are valid array declaration?

  1. Object array[];

  2. Boolean array[3];

  3. int[] array;

  4. Float[2] array;

Answer: A,C

100% Ensurepass Free Download!
Download Free Demo:1z0-808 Demo PDF
100% Ensurepass Free Guaranteed!
1z0-808 Dumps

EnsurePass ExamCollection Testking
Lowest Price Guarantee Yes No No
Up-to-Dated Yes No No
Real Questions Yes No No
Explanation Yes No No
PDF VCE Yes No No
Free VCE Simulator Yes No No
Instant Download Yes No No

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.