Question
Hopefully I can get some help for these questions.. Thanks! 1-Which of the following are true for integer division? a) 0/0 == 1 b) 1/2
Hopefully I can get some help for these questions.. Thanks!
1-Which of the following are true for integer division? a) 0/0 == 1 b) 1/2 == 0.5 c) 8/-3 == -2 d) (-1)/2 == -1 e) 8/3 == 2 f) 99/100 == 0 g) 8/3 == 3 h) 1/2 == 0
2-Why should an instance variable (field) never be public? Check all the reasons
a) To force the client to call methods instead. b) So that the class can be immutable. c) To avoid an exception being thrown. d) To prevent other classes from accidentally setting it to an invalid value. e) To prevent inefficient code. f) To prevent common errors on use.
3-Suppose we execute the following code:
Point p, q, r, s; p = new Point(3,4); // Create a point with x=3, y=4 q = new Point(3,4); r = new Point(10,20); s = r; q.setLocation(10,20); // Change x to 10 and y to 20 s.setLocation(3,4);
How many of the following conditions are true? Check all that apply. a) r.getX() == 3 b) p == q - correct answer c) p.getX() == 3 d) r == s - correct answer e) p == s f) s.getX() == 3 g) q == r h) q.getX() == 3
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started