CMSC 131 Study Guide - Midterm Guide: Instance Variable

146 views8 pages

Document Summary

I pledge on my honor that i have not given or received any unauthorized assistance on this examination. This exam is a closed-book and closed-notes exam. The exam is a 50 minutes exam. Please use a pencil to complete the exam. If we cannot understand your answer, we will not grade it (i. e. , 0 credit). Problem 1 (16 pts: (1 pt) name one class discussed in class that is immutable. Answer: we should use static when all instances of the class will use the same constant value: (6 pts) based on the following class, indicated whether the statements below are valid or invalid. Circle private string make; public computer(string makein) { make = makein; } public void setmake(string makein) { make = makein; } public static void info() { system. out. println("computer sys"); } your answer. public class computer { Answer/grading: (1 pt) each: computer c1 = new computer("sun"); Valid c4. info(): computer c5 = new computer("jupiter"); c5. make = "uranus";