Oracle Java SE 1z1-819 Practice Test Engine: Try These 297 Exam Questions
Guaranteed Success in Oracle Java SE 1z1-819 Exam Dumps
NEW QUESTION # 81
Given the code fragment:
What should be inserted at line n1 so that the code fragment prints Name is required?
- A. name.trim() == '' ''
- B. name. compareTo('' '') == 0
- C. name.isEmpty
- D. name, isBlanl ()
Answer: D
NEW QUESTION # 82
Given:
What is the result?
- A. 0
- B. 1
- C. An exception is thrown at runtime.
- D. 2
Answer: A
Explanation:
NEW QUESTION # 83
Which two safely validate inputs? (Choose two.)
- A. Delegate numeric range checking of values to the database.
- B. Accept only valid characters and input values.
- C. Use trusted domain-specific libraries to validate inputs.
- D. Assume inputs have already been validated.
- E. Modify the input values, as needed, to pass validation.
Answer: A,B
Explanation:
Reference:
/validating-input-using-java-util-scanner
NEW QUESTION # 84
Given the code fragment:
You must make the countvariable thread safe.
Which two modifications meet your requirement? (Choose two.)
- A. replace line 3 with
synchronized(test.count) {
test.count++;
} - B. replace line 2 with public static synchronized void main(String[] args) {
- C. replace line 1 with private AtomicInteger count = new AtomicInteger(0);and replace line 3 with test.count.incrementAndGet();
- D. replace line 3 with
synchronized(test) {
test.count++;
} - E. replace line 1 with private volatile int count = 0;
Answer: A,C
Explanation:
Explanation/Reference: https://stackoverflow.com/questions/15852123/java-thread-safe-counter/15852164
NEW QUESTION # 85
Given:
What is the result?
- A. 0 4 9
- B. 0
- C. 1
- D. nothing
Answer: D
NEW QUESTION # 86
Given:
Which two statements can be added at line 1 in Bar to successfully compile it? (Choose two.)
- A. public List<Integer> foo(TreeSet<String> m) { ... }
- B. public ArrayList<Number> foo(Set<CharSequence> m) { ... }
- C. public List<Object> foo(Set<CharSequence> m) { ... }
- D. public ArrayList<Integer> foo(Set<String> m) { ... }
- E. public List<Integer> foo(Set<String> m) { ... }
- F. public List<Integer> foo(Set<CharSequence> m) { ... }
Answer: A,B
NEW QUESTION # 87
Given:
Which two codes, independently, can be inserted in line to 1 compile?
- A. Abacus aba = (int i, j) -> ( return i * j; };
- B. Abacus aba = v, w -> x * y;
- C. Abacus aba = (a, b) -> a * b;
- D. Abacus aba = (int m, int n) -> { m * n };
- E. Abacus aba = (int e, int f) -> { return e * f; };
Answer: A,C
NEW QUESTION # 88
Given:
What is the result?
- A. SomeClass#methodA()SomeClass#methodA()
- B. AnotherClass#methodA()SomeClass#methodA()
- C. AnotherClass#methodA()AnotherClass#methodA()
- D. A ClassCastException is thrown at runtime.
- E. SomeClass#methodA()AnotherClass#methodA()
- F. The compilation fails.
Answer: F
Explanation:
NEW QUESTION # 89
Given:
What is the output?
- A. Exception
- B. 0
- C. 1
- D. 2
Answer: C
Explanation:
NEW QUESTION # 90
Given:
Which statement is true about the Fox class?
- A. Fox class does not have to override the inhabit method if Forest and Town provide compatible implementations.
- B. The inhabit method implementation from the first interface that Fox implements will take precedence.
- C. Fox class must implement either Forest or Town interfaces, but not both.
- D. Fox class does not have to override inhabit method, so long as it does not try to call it.
- E. Fox class must provide implementation for the inhabit method.
Answer: A
NEW QUESTION # 91
Given:
Assuming that this code compiles correctly, which three statements are true? (Choose three.)
- A. A cannot be abstract.
- B. B cannot be final.
- C. A cannot be final.
- D. A is a subtype of B.
- E. B cannot be abstract.
- F. B is a subtype of A.
Answer: C,E,F
NEW QUESTION # 92
Given:
Which two lines cause compilation errors? (Choose two.)
- A. line 7
- B. line 6
- C. line 12
- D. line 9
- E. line 8
Answer: A,B
NEW QUESTION # 93
Given:
What is the result?
- A. A java.lang.IllegalArgumentException is thrown.
- B. 0
- C. 1
- D. nothing
- E. It fails to compile.
Answer: E
Explanation:
NEW QUESTION # 94
Given the formula to calculate a monthly mortgage payment:
and these declarations:
How can you code the formula?
- A. m = p * (r * Math.pow(1 + r, n) / (Math.pow(1 + r, n) - 1));
- B. m = p * r * Math.pow(1 + r, n) / Math.pow(1 + r, n) - 1;
- C. m = p * ((r * Math.pow(1 + r, n) / (Math.pow(1 + r, n)) - 1));
- D. m = p * (r * Math.pow(1 + r, n) / Math.pow(1 + r, n) - 1);
Answer: A
NEW QUESTION # 95
Given this enum declaration:
Examine this code:
System.out.println(Letter.values()[1]);
What code should be written at line 5 for this code to print 200?
- A. public String toString() { return String.valueOf(Letter.values()[1]); }
- B. public String toString() { return String.valueOf(ALPHA.v); }
- C. public String toString() { return String.valueOf(v); }
- D. String toString() { return "200"; }
Answer: C
Explanation:
NEW QUESTION # 96
Given:
and
Which two method definitions at line n1 in the Bar class compile? (Choose two.)
- A. public List<Number> foo(Set<String> m) {...}
- B. public List<Integer> foo(TreeSet<String> m) {...}
- C. public List<Integer> foo(Set<CharSequence> m) {...}
- D. public ArrayList<Integer> foo(Set<String> m) {...}
- E. public List<Object> foo(Set<CharSequence> m) {...}
- F. public ArrayList<Number> foo(Set<CharSequence> m) {...}
Answer: B,F
NEW QUESTION # 97
Given:
Which two method implementations are correct, when inserted independently in line 1? (Choose two.)
- A. Option B
- B. Option E
- C. Option C
- D. Option A
- E. Option D
Answer: B,D
NEW QUESTION # 98
Given:
If file "App.config" is not found, what is the result?
- A. Configuration is OK
- B. Exception in thread "main" java.lang.Error:Fatal Error: Configuration File, App.config, is missing.
- C. nothing
- D. The compilation fails.
Answer: D
Explanation:
NEW QUESTION # 99
Which two statements are correct about modules in Java? (Choose two.)
- A. java.base exports all of the Java platforms core packages.
- B. A module must be declared in module-info.java file.
- C. module-info.java cannot be empty.
- D. By default, modules can access each other as long as they run in the same folder.
- E. module-info.java can be placed in any folder inside module-path.
Answer: A,B
NEW QUESTION # 100
Which two expressions create a valid Java Path instance? (Choose two.)
- A. Path.get(new URI("file:///domains/oracle/test.txt"))
- B. new Path("foo")
- C. Paths.get(URL.create("file:///domains/oracle/test.txt"))
- D. Paths.getPath("too")
- E. Paths.get("foo")
Answer: C,E
NEW QUESTION # 101
Given:
What code must you insert on Line 1 to enable the code to print Hello world?
- A. Hello myH = new Hello();
Hello.Greeting myG = myH.new Greeting();
myG.sayHi(); - B. Hello.Greeting myG = new Hello.Greeting() myG.sayHi();
- C. Hello myH = new Hello(); Greeting myG = new Greeting(); myG.sayHi ();
- D. Hello myH = new Hello();
Hello.Greeting myG = myH.new Hello.Greeting();
myG.sayHi();
Answer: A
NEW QUESTION # 102
......
Test Engine to Practice 1z1-819 Test Questions: https://www.actualcollection.com/1z1-819-exam-questions.html