24. Consider the following class definition. public class SomeClass private int x = 0; private static int y = 0: public
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
24. Consider the following class definition. public class SomeClass private int x = 0; private static int y = 0: public
24. Consider the following class definition. public class SomeClass private int x = 0; private static int y = 0: public SomeClass(int px) x = px; y++; public void incrementY() { y++; } public void incrementy (int inc) (y += inc; ) public int getY() { return y; } The following code segment appears in a class other than SomeClass. SomeClass first = new SomeClass(10); SomeClass second = new SomeClass (20); SomeClass third = new SomeClass (30); first.incrementY(); second. incrementy (10); System.out.println (third.getY()); What is printed as a result of executing the code segment if the code segment is the first use of a SomeClass object? (A) 0 (B) 1 (C) 11 (D) 14 (E) 30
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!