📘 Free 1Z0-808 Sample Questions
Given:
A
200.0 : 100.0
B
400.0 : 200.0
C
400.0 : 100.0
D
Compilation fails.
Correct Answer:
C. 400.0 : 100.0
Explanation:
Answer - (c)
as newPrice variable is not getting updated. The instance variable price is getting updated
Given the code fragment:
A
10 Hello World!
B
Hello Universe!
C
Hello World!
D
Compilation fails.
Correct Answer:
A. 10 Hello World!
Explanation:
The answer is A, because the update of variable aVar, is made the next time is used, this happen when we
using ++ on end of variable.
Given the code fragment:
A
May 04, 2014T00:00:00.000
B
2014-05-04T00:00: 00.000
C
5/4/14T00:00:00.000
D
An exception is thrown at runtime.
Correct Answer:
D. An exception is thrown at runtime.
Explanation:
Answer is D.Source code throws "Exception in thread "main"
java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: HourOfDay"To
test:Remember:import java.time.LocalDate;import java.time.format.DateTimeFormatter;public static void
main(String[] args) String date = LocalDate .parse("2014-05-04")
format(DateTimeFormatter.ISO_DATE_TIME);System.out.println(date);
Given the code fragment:
A
Sum is 600
B
Compilation fails at line n1.
C
Compilation fails at line n2.
D
A ClassCastException is thrown at line n1.
E
A ClassCastException is thrown at line n2.
Correct Answer:
C. Compilation fails at line n2.
Explanation:
C. This is a casting issue but the code fails to compile so the answer is c. The Class Cast Exception is a runtime
exception where you're trying to cast an object to a different object type, but here the code fails to compile
because you cannot cast a long to a string.
What is the name of the Java concept that uses access modifiers to protect variables and hide them within a class?
A
Encapsulation
B
Inheritance
C
Abstraction
D
Instantiation
E
Polymorphism
Correct Answer:
A. Encapsulation
Explanation:
Using the private modifier is the main way that an object encapsulates itself and hide data from the outside
world.
Reference:
http://www.tutorialspoint.com/java/java_access_modifiers.htm
Given the code fragment:
A
Make the method at line n1 public.
B
Make the method at line n2 public.
C
Make the method at line n3 public.
D
Make the method at line n3 protected.
E
Make the method at line n4 public.
Correct Answer:
C. Make the method at line n3 public.
Explanation:
C. Make the method at line n3 public.
D. Make the method at line n3 protected.
Given:
A
4W 100 Auto 4W 150 Manual
B
Null 0 Auto 4W 150 Manual
C
Compilation fails only at line n1
D
Compilation fails only at line n2
E
Compilation fails at both line n1 and line n2
Correct Answer:
E. Compilation fails at both line n1 and line n2
Explanation:
1. Answer is E.
2. Constructor call must be the first statement in a constructor
Given the code fragment:
A
Option A
B
Option B
C
Option C
D
Option D
E
Option E
Correct Answer:
A. Option A
Explanation:
Answer: AC B is not valid. unreachable line on catching the IO Exception in Option B.
Given the following two classes:
A
Option A
B
Option B
C
Option C
D
Option D
Correct Answer:
B. Option B
Explanation:
A allows negative. C is private and not access able by another class. D is not assigned in right way.
Given the code fragment:
A
Match 1
B
Match 2
C
No Match
D
A Null Pointer Exception is thrown at runtime.
Correct Answer:
B. Match 2
Explanation:
Answer: B
new String Builder(5) specifies the initial capacity but the assigning content in it.
however, it doesn't mean that you cannot put more than 5 characters in the String Builder. it just means that it
reserves space for 95characters when you create the String Builder. When you put in more characters, it will
grow automatically. The capacity is not fixed to what you pass the constructor, it's just the initial capacity.
Questions: 1-10 out of 235
Continue Full Practice..
GET ALL 235 QUESTIONS