Jump to content

Recommended Posts

Posted

[quote name='bantrothu bullabbai' timestamp='1344037434' post='1302254535']
vadedo tension lo vachi adugutunte help cheyakunda aa navventi.... spamming cheyadaniki vachinappudu chey ilantivi.... I(*&
[/quote]
[img]http://www.andhrafriends.com/uploads/profile/photo-thumb-11780.jpg?_r=1343458967[/img]

  • 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

[quote name='cherlapalli_jailer' timestamp='1344037567' post='1302254542']
[/quote] CITI_$D#

Posted

once u try let me know i will tell how to pass num 1 and num 2 as params from command prompt and u can play around

Posted

[quote name='cherlapalli_jailer' timestamp='1344037567' post='1302254542']
[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]"[b]SUB [/b]"[/color][/color]+o.sub(num1, num2));

}[/size]


[size=2]try this[/size]
[/quote]

@gr33d @gr33d s%H# s%H#

Posted

[quote name='HAPPYLESS' timestamp='1344037595' post='1302254546']
[img]http://www.andhrafriends.com/uploads/profile/photo-thumb-11780.jpg?_r=1343458967[/img]
[/quote]em mama kanipistale.... ne kosam gif cheddam ante time dorakatle....

Posted

naaku java raadhu.. C# lo raasta.. convert sesko..


public static void main() //string[] args idhi command line variable passing kosam.. ikkada avasaram ledu..
{
console.WriteLine("Enter first Number for operation");
int a = convert.int32(console.ReadLine());
console.WriteLine("Enter second Number for operation");
int b = convert.int32(console.ReadLine());
operations obj = new operations();
int resultadd = obj.add(a, b ) ;
int resultsub = obj.sub(a, b ) ;

}

Posted

hava emi ayyipoyadu

ok mean while let me prepare command line also

Posted

[quote name='cherlapalli_jailer' timestamp='1344037641' post='1302254552']
once u try let me know i will tell how to pass num 1 and num 2 as params from command prompt and u can play around
[/quote]
mama got it u r right coz i didn't implement any methods in abstract class and I can use Interface and implement it instead of extending it by using abstract class and now I changed the code by implementing a method in abstract class itself coz my home work is to do this task by an abstract class... thanks mama and I'll try the code that u have given :)

Posted

eclipse vadithe aa project meeda right click press chesi run
loo aurgument pass cheyachu

Posted

args if you are using simple jdk with command prompt pass using
java -d operations arg1 arg2.
if eclipse,run config lo set chey

then read those args in main method
then create instance of the class and call methods..then print op

Posted

[quote name='bantrothu bullabbai' timestamp='1344037726' post='1302254561']
em mama kanipistale.... ne kosam gif cheddam ante time dorakatle....
[/quote]
[img]http://lh6.ggpht.com/-rwn7cH72Szg/T9VQrGGwg8I/AAAAAAAAGno/ak_BQ7XyqFc/s150/Trivikram.gif[/img] edho kothi bommalu eskuntu bathukuthunna [img]http://lh6.ggpht.com/-rwn7cH72Szg/T9VQrGGwg8I/AAAAAAAAGno/ak_BQ7XyqFc/s150/Trivikram.gif[/img]

nuvvu ila gif create sesi target sesthe tub lo dooki suicide seskunta [img]http://lh6.ggpht.com/-rwn7cH72Szg/T9VQrGGwg8I/AAAAAAAAGno/ak_BQ7XyqFc/s150/Trivikram.gif[/img]

Posted

when u r using absract class u can,t implement multiple inheritance so to implement multiple inheritance we use interface

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 [color=#ff0000][b][size=5]how to pass the variables[/size][/b][/color] 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]


public class Hello
{
public static void main(String[] args)
{
System.out.println("Hava "+args[0]);
}
}

tarvata command line lo
[b]java Hello is good[/b][font=Verdana, sans-serif] to pass the parameter "is good" to the program and the output is "hava is good" . [/font]

Posted

public abstract class Calc{
public abstract int add(int num1,int num2);
public abstract int sub(int num1,int num2);
}





public class Operations extends Calc {
public int add(int num1,int num2){

return num1+num2;
}
public int sub(int num1,int num2){
return num1-num2;
}
}





import java.util.Scanner;


public class CalcTest {
public static void main(String args[]){
Operations op=new Operations();
Scanner sc=new Scanner(System.in);
System.out.println("enter '1' to perform addition and '2' for substraction");
int opn=sc.nextInt();
if(opn==1){
System.out.println("enter your numbers");
int num1=sc.nextInt();
int num2=sc.nextInt();
System.out.println("values is "+op.add(num1, num2));
}
else if(opn==2){
System.out.println("enter your numbers");
int num1=sc.nextInt();
int num2=sc.nextInt();
System.out.println("value is "+op.sub(num1, num2));
}else{
System.out.println("no matching operation found");
}
}
}


total 3 classess :police: :police: :police:

×
×
  • Create New...