Go Back on 1z0-808 Exam
Available in 1, 3, 6 and 12 Months Free Updates Plans
PDF: $15 $60

Test Engine: $20 $80

PDF + Engine: $25 $99

1z0-808 Practice Test


Page 3 out of 48 Pages

Consider following method

Which statement is true?


A.

 This method is invalid.


B.

This method can be used only in an interface.


C.

This method can return anything.


D.

This method can be used only in an interface or an abstract class.


E.

None of above.





B.
  

This method can be used only in an interface.



Given method is declared as default method so we can use it only inside an interface.
Hence option B is correct and option D is incorrect.
Option A is incorrect as it is valid method. Option C is incorrect as return type is void, which
means we can't return anything.

Given:
public class FieldInit {
char c;
boolean b;
float f;
void printAll() {
System.out.println("c = " + c);
System.out.println("c = " + b);
System.out.println("c = " + f);
}
public static void main(String[] args) {
FieldInit f = new FieldInit();
f.printAll();
}
}
What is the result?


A.

c = null
b = false
f = 0.0F


B.

c = 0
b = false
f = 0.0f


C.

c = null
b = true
f = 0.0


D.

c =
b = false
f = 0.0





D.
  

c =
b = false
f = 0.0



Given the following main method:

What is the result?


A.

5 4 3 2 1 0


B.

5 4 3 2 1


C.

4 2 1


D.

5


E.

Nothing is printed





D.
  

5



Loop will run only once and after that num == 0 will break it
After first cycle of the loop.

Given the code fragment:
class Student {
int rollnumber;
String name;
List cources = new ArrayList();
// insert code here
public String toString() {
return rollnumber + " : " + name + " : " + cources;
}
}
And,
public class Test {
public static void main(String[] args) {
List cs = newArrayList();
cs.add("Java");
cs.add("C");
Student s = new Student(123,"Fred", cs);
System.out.println(s);
}
}
Which code fragment, when inserted at line // insert code here, enables class Test to print
123 : Fred : [Java, C]?


A.

private Student(int i, String name, List cs) {
/* initialization code goes here */
}


B.

public void Student(int i, String name, List cs) {
/* initialization code goes here */
}


C.

Student(int i, String name, List cs) {
/* initialization code goes here */
}


D.

Student(int i, String name, ArrayList cs) {
/* initialization code goes here */
}





C.
  

Student(int i, String name, List cs) {
/* initialization code goes here */
}



Incorrect:
Not A: Student has private access line: Student s = new Student(123,"Fred", cs);
Not D: Cannot be applied to given types. Line: Student s = new Student(123,"Fred", cs);


A.

Option A


B.

Option B


C.

Option C


D.

Option D





D.
  

Option D




Page 3 out of 48 Pages
Previous