View the step-by-step solution to:

Question

Screen Shot 2019-12-11 at 1.41.04 AM.png

get the s1 and s3, plz

show the process for how it works, I get the output which confused me, for example s1's cumulative increase 3 times, why will be that happen, it should be add just 1, but output 3. And Why id is not same as cumulative?

Screen Shot 2019-12-11 at 1.41.04 AM.png

private int id;
private String name;
public static int culmulative = 0;
public Q6 (String name) {
this . name = name;
culmulative++;
id = culmulative;
public String toString( ) {
return name + ", " + id + ", " + culmulative;
public static void main (String args) {
/ / TODO Auto-generated method stub
Q6 s1 = new Q6 ("Ace" ) ;
Q6 s2 = new Q6 ( "Base") ;
Q6 s3 = new Q6 ( "Case") ;
System. out . print ln(s1);
s2. culmulative = 10;
System. out . print ln(s3) ;
LP

Top Answer

cumulative is a static variable , whereas id is a simple variable Static variable are not the simple variables they(static... View the full answer

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question