24. Consider the following class definition. public class SomeClass private int x = 0; private static int y = 0: public

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
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

Post by answerhappygod »

24 Consider The Following Class Definition Public Class Someclass Private Int X 0 Private Static Int Y 0 Public 1
24 Consider The Following Class Definition Public Class Someclass Private Int X 0 Private Static Int Y 0 Public 1 (27.69 KiB) Viewed 67 times
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!
Post Reply