exam questions

Exam 1z0-819 All Questions

View all questions & answers for the 1z0-819 exam

Exam 1z0-819 topic 1 question 53 discussion

Actual exam question from Oracle's 1z0-819
Question #: 53
Topic #: 1
[All 1z0-819 Questions]

Given:



Which is true?

  • A. Code compiles but throws a runtime exception when run.
  • B. It prints 666.
  • C. The code compiles and runs successfully but with a wrong answer (i.e., a bug).
  • D. The code does not compile successfully.
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
06d854e
4 months ago
Ans: B its prints 666
upvoted 1 times
...
ASPushkin
5 months, 1 week ago
Selected Answer: D
Java Spec 16 Definite Assignment Each local variable ... must have a definitely assigned value when any access of its value occurs. 14.4.2 Scope of Local Variable Declarations "causes a compile-time error because the initialization of x is within the scope of the declaration of x as a local variable, and the local x does not yet have a value and cannot be used." The same result will be even without static declaration like : class Scope { public static void main(String[]) { int myint = myint; System.out.println(myint); } }
upvoted 1 times
...
tmuralimanohar
1 year, 6 months ago
Answer: D
upvoted 2 times
...
Stavok
1 year, 7 months ago
Selected Answer: D
D is correct
upvoted 2 times
...
Mukes877
1 year, 7 months ago
Selected Answer: D
D is correct because the local variable myint is not successfully initialized. You can use int myint = Scope.myint;
upvoted 2 times
...
RP384
1 year, 11 months ago
Selected Answer: D
Compile time issue
upvoted 2 times
...
Ankit1010
1 year, 11 months ago
D is the correct answer. Compile Time issue. You can use int myint = Scope.myint to reference to the class level static variable.
upvoted 3 times
...
TADIEWA
2 years ago
D local variable myint is not initialized , u can use int myint = this.myint to reference the class variable myint
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago