Question: Question 12 Given: public class Telescope { static int magnify = 2; public static void main(String[] args) { go(); } static void go() { int

Question 12

Given: public class Telescope { static int magnify = 2; public static void main(String[] args) { go(); } static void go() { int magnify = 3; zoomIn(); } static void zoomIn() { magnify *= 5; zoomMore(magnify); System.out.println(magnify); } static void zoomMore(int magnify) { magnify *= 7; } }

What is the result?

A. 2

B. 10

C. 15

D. 30

E. 70

F. 105

G. Compilation fails

Answer :

B is correct. In the Telescope class, there are three different variables named magnify. The go() method's version and the zoomMore() method's version are not used in the zoomIn() method. The zoomIn() method multiplies the class variable * 5. The result (10) is sent to zoomMore(), but what happens in zoomMore() stays in zoomMore(). The S.O.P. prints the value of zoomIn()'s magnify. A, C, D, E, F, and G are incorrect based on the above. (OCA Objectives 1.1 and 6.8)

REquired:

please explain why answer is correct and why not ? please explain in detail /

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!