Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I ' m trying to get a return result of 1 0 , but it keeps printing 0 . Can you tell me

I'm trying to get a return result of 10, but it keeps printing "0". Can you tell me what I'm not doing? This is the code so far:
public class Untitled {
public static void main(String[] args){
int returning =5;
One one = new One();
one.gone(returning);
System.out.println(one.pass());
}
}
class One{
private Two tone;
public void gone(int one){
tone = new Two();
tone.Two(one);
}
public int pass(){
tone = new Two();
return tone.passes();
}
}
class Two{
private int two;
Two(int two){
this.two=two;
}
Two(){}
public void Two(int one){
two=two+one;
}
public int passes(){
System.out.println(two);
return two;
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mastering Apache Cassandra 3 X An Expert Guide To Improving Database Scalability And Availability Without Compromising Performance

Authors: Aaron Ploetz ,Tejaswi Malepati ,Nishant Neeraj

3rd Edition

1789131499, 978-1789131499

More Books

Students also viewed these Databases questions

Question

socialist egalitarianism which resulted in wage levelling;

Answered: 1 week ago

Question

soyuznye (all-Union, controlling enterprises directly from Moscow);

Answered: 1 week ago