exam questions

Exam 1z0-808 All Questions

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

Exam 1z0-808 topic 1 question 178 discussion

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

Given the definitions of the MyString class and the Test class:

What is the result?
A.

B.

C.

D. Compilation fails at the Test class

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
MPignaProTech
2 months, 3 weeks ago
A is the good answer
upvoted 1 times
...
akbiyik
2 years, 1 month ago
Answer is A.
upvoted 2 times
...
carloswork
2 years, 2 months ago
Answer is A. To test: class MyString { String msg; MyString(String msg){ this.msg=msg; } } public class Test { public static void main(String[] args) { System.out.println("Hello " + new StringBuilder("Java SE 8")); System.out.println("Hello " + new MyString("Java SE 8").msg); } }
upvoted 3 times
...
iSnover
2 years, 3 months ago
The correct answer is the letter A. when we put a "." after a variable we can call a method or an attribute of it. Notice that the "println" method already calls the attributes, so when we instantiate the "new MyString("Java SE 8")" and after placing the ".msg" we are directly accessing the var "msg" which is "Java SE 8" printing the same normally. I tested it if you want: class MyString { String msg; MyString(String msg) { this.msg = msg; } } public class Test { public static void main (String[] args) { System.out.println("Hello " + new StringBuilder("Java SE 8")); System.out.println("Hello " + new MyString("Java SE 8").msg); } }
upvoted 3 times
...
alex_au
2 years, 3 months ago
Correct answer should be A. As the two classes are in the same package (p1.MyString and p1.Test), they don't need to be imported from one another.
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