3.11. Sample exam questions
Which option defines a well-encapsulated class?
class Template { public String font; } class Template2 { public String font; public void setFont(String font) { this.font = font; } public String getFont() { return font; } } class Template3 { private String font; public String author; public void setFont(String font) { this.font = font; } public String getFont() { return font; } public void setAuthor(String author) { this.author = author; } public String getAuthor() { return author; } }- None of the above
Examine the following code and select the correct option(s):
public class Person { public int height; public void setHeight(int newHeight) { if (newHeight <= 300) height = newHeight; ...
Get OCA Java SE 8 Programmer I Certification Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.