Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 102

Given the code fragment:

Which two code snippets inserted independently inside println method print Mondial:domainmodel? (Choose two.)

    Correct Answer: C, D

    To print 'Mondial:domainmodel', the code must concatenate the 'prefix' static field and the 'name' instance field. Option C works because it correctly uses the static 'prefix' field and calls the static 'getName()' method which returns the 'name' field from a new Main instance. Option D works because it creates a new instance of Main to access both 'prefix' and 'name' fields directly, ensuring it uses their values properly.

Discussion
StavokOptions: CD

C & D are correct TESTED

ASPushkinOption: C

C - access to private modifier inside the class is Ok (doesn't matter which instance)

ObaltOptions: CD

Correct answer is C & D