exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 62 discussion

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

Given the content of three files:

Which statement is true?

  • A. Only the A.Java file compiles successfully.
  • B. Only the B.java file compiles successfully.
  • C. Only the C.java file compiles successfully.
  • D. The A.Java and B.java files compile successfully.
  • E. The B.java and C.java files compile successfully.
  • F. The A.Java and C.java files compile successfully.
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

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
ashwinbalu
Highly Voted 4 years, 7 months ago
Correct answer is A. class B won't compile as we can't have private or protected variables in a block. class C won't compile as package declaration should be first statement followed by import statement (s).
upvoted 21 times
...
Stewart125
Highly Voted 4 years, 3 months ago
Comments here are incorrect as to why C won't compile. The format should be; Package Imports Class
upvoted 6 times
...
MPignaProTech
Most Recent 3 months ago
Selected Answer: A
On ly A compile. in B we have private variable in a block this cannot compile
upvoted 1 times
...
DriftKing
1 year, 4 months ago
Selected Answer: A
Only A.java wile compile. Class B won't compile because the scope of the local variables belong to the method/block/constructor/ these are not accessed from outside, therefore, having access specifiers like public, private, protected (which allows access outside of the current context) makes no sense. Class C won't compile as package should be the first statement and then import.
upvoted 2 times
...
dsms
1 year, 5 months ago
correct answer is: The B.java and C.java files compile successfully.
upvoted 1 times
...
Vicky_65
1 year, 9 months ago
Selected Answer: A
A is correct
upvoted 1 times
...
gfdhsfgcdfs
2 years, 5 months ago
C.java will not compile because you cannot create private variables inside a method.
upvoted 1 times
...
rameasy
4 years, 5 months ago
Correct answer is A. C will not compile as the class name of C.java is A.
upvoted 1 times
...
zelimir
4 years, 10 months ago
F - C compiles successfully too
upvoted 1 times
krkpnr
4 years, 10 months ago
Main method must be static
upvoted 1 times
Saftschnitzel
4 years, 9 months ago
Not true. You can have a method called main, which is not static, but cannot be compiled through the command line directly. The issue here is the package statement following the import statement, when it should be the other way round.
upvoted 8 times
natiqbashir
3 years, 11 months ago
Sorry, but you both wrong. Check the order of package and import statements in the C class
upvoted 1 times
...
...
...
...
v323rs
5 years ago
A - correct, Only the A.Java file compiles successfully.
upvoted 5 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