Jump to content

Recommended Posts

Posted

package Name --> Calculator

I created an abstract class Calc--> I had give some abstract method addition and subtract
public abstract class Calc
{
public abstract int add(num1,num2);
public abstract int sub(num1,num2);
}

I extended this Calc class in Operations class which should inherit the abstract method from Calc class and I implemented these both abstract methods in Operations class.
public class Operations extends Calc
{
public int add(int num1, int num2)
{
System.out.println("the result is");
return num1+num2;
}
public int sub(int num1, int num2);
{
System.out. println("the result is"):
}
}

So, these are the Abstract class and their respective implementation right... now I have to creare a TEST CASE fot these...So,
public class CalcTest
{
public static void main(string[] args)
{
----------------------;
---------------------;
----------------------;
}

Please fill the blanks so that the o/p of the program should be addition of two variables num1 and num2 and subtraction of num1 and num2.


[size=5]My guess:[/size]
So, I guess to pass the arguments here in the test case through command line so how to pass the variables and also I think we need to create an instance of the Operations class but I'm not sure I'm stuck here please help me with this simple JAVA code *<:( *<:(

  • Replies 103
  • Created
  • Last Reply

Top Posters In This Topic

  • hava

    44

  • cherlapalli_jailer

    17

  • soulmate

    11

  • Aamayakudu

    7

Top Posters In This Topic

Posted

just came checking

Posted
CITI#H@ chy mama pls malli ellali nenu[quote name='battalsatti' timestamp='1344036882' post='1302254499']
java meeda padi db ni marchipotava?? ^G#W ^G#W
[/quote]
Posted

nenu raasina ippati dhaaka code lo em ayina thappulu unna cheppandi... kaasthe please :(

Posted

Change abstract to interface and extend to implement

Posted

[quote name='hava' timestamp='1344036748' post='1302254489']
package Name --> Calculator

I created an abstract class Calc--> I had give some abstract method addition and subtract
public abstract class Calc
{
public abstract int add(num1,num2);
public abstract int sub(num1,num2);
}

I extended this Calc class in Operations class which should inherit the abstract method from Calc class and I implemented these both abstract methods in Operations class.
public class Operations extends Calc
{
public int add(int num1, int num2)
{
System.out.println("the result is");
return num1+num2;
}
public int sub(int num1, int num2);
{
System.out. println("the result is"):
}
}

So, these are the Abstract class and their respective implementation right... now I have to creare a TEST CASE fot these...So,
public class CalcTest
{
public static void main(string[] args)
{
----------------------;
---------------------;
----------------------;
}

Please fill the blanks so that the o/p of the program should be addition of two variables num1 and num2 and subtraction of num1 and num2.


[size=5]My guess:[/size]
So, I guess to pass the arguments here in the test case through command line so how to pass the variables and also I think we need to create an instance of the Operations class but I'm not sure I'm stuck here please help me with this simple JAVA code *<:( *<:(
[/quote]


nuvvu variables pass cheyyadaniki Scanner ani vuntundi vayya.. see the below link
[url="http://javaeschool.com/java-examples/java-scanner-example/"]http://javaeschool.com/java-examples/java-scanner-example/[/url]

Posted

yevarikina Java telisthey....Guyz help him,..rather discoing in other threads....

Posted

[quote name='cherlapalli_jailer' timestamp='1344037146' post='1302254515']
Change abstract to interface and extend to implement
[/quote]
mama we can do this using abstract too kadha bhayya... If suppose I implement a method in abstract class?

Posted
*<:( CITI#H@ [quote name='Silver_mani' timestamp='1344037248' post='1302254524']
hava CITI_c$y CITI_c$y CITI_c$y
[/quote]
Posted

[quote name='Silver_mani' timestamp='1344037248' post='1302254524']
hava CITI_c$y CITI_c$y CITI_c$y
[/quote]vadedo tension lo vachi adugutunte help cheyakunda aa navventi.... spamming cheyadaniki vachinappudu chey ilantivi.... *(*(* I(*&

Posted

[quote name='hava' timestamp='1344037381' post='1302254530']
*<:( CITI#H@
[/quote]
#~` #~`

Posted

[b][size=2][color=#7F0055][size=2][color=#7F0055]public[/color][/size][/color][/size][/b]


[size=6][b][color=#7F0055][color=#7F0055]static[/color][/color][/b] [b][color=#7F0055][color=#7F0055]void[/color][/color][/b] main(String[] args)
{
Oparations o =
[b][color=#7F0055][color=#7F0055]new[/color][/color][/b] Oparations() ;

[b][color=#7F0055][color=#7F0055]int[/color][/color][/b] num1 = 100 ;

[b][color=#7F0055][color=#7F0055]int[/color][/color][/b] num2 = 50 ;

System.
[i][color=#0000C0][color=#0000C0]out[/color][/color][/i].println([color=#2A00FF][color=#2A00FF]"add"[/color][/color]+o.add(num1, num2));
System.
[i][color=#0000C0][color=#0000C0]out[/color][/color][/i].println([color=#2A00FF][color=#2A00FF]"add"[/color][/color]+o.sub(num1, num2));

}[/size]


[size=2]try this[/size]

×
×
  • Create New...