Question:

Can you solve this java question? ?

by  |  earlier

0 LIKES UnLike

class Start{

int x;

int go(int n){x+=n;return x;}

void print(){

System.out.println("Start: "+x);

}

}

class Finish extends Start{

int go(int n){x-=n;return x;}

void print(){

System.out.println("Finish: "+x);

}

}

public class Class1

{

public static void main (String[] args)

{

Start s1=new Start(), s2= new Finish(),

s3= new Finish(){

int go(int n){x+=2*n;return n;}

};

s1.go(s2.go(s3.go(s2.go(s1.go(3)))));

s1.print();s2.print();s3.print();

}

}

 Tags:

   Report

1 ANSWERS


  1. this is why I hate java

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions