are the both following codes do same work?
Code:dog[] pets; pets= new dog[7];
Code:dog[] pets=new dog[7];
also
I need a good description about get and set methods
dog d1=new dog();
dog[] d=new dog[7];
dog[0]=new dog();
dog[1]=new dog();
//...and so on
dog[] d=new dog[7];
dog[0]=new dog();
dog[1]=new dog();
//...and so on
dog[] d=new dog[7];
[B]d[0][/B]=new dog();
[B]d[1][/B]=new dog();
//...and so on
d1.bark();
d[0].bark();
thanks garbage
I wanted to ask something on interfaces and polymorphism
will post as soon as I get an appropriate code
[B]class animal[/B]
{
eat();
sleep();
noise();
}
[B]class dog extends animal[/B]
{
eat()
{
//statements
}
noise()
{
//statements
}
}
[B]class lion extends animal[/B]
{
eat()
{
//statements
}
noise()
{
//statements
}
}
[B]class hippo extends animal[/B]
{
eat()
{
//statements
}
noise()
{
//statements
}
}
[B]class vet(animal a)[/B]
{
cure()
{
//statements
}
}
[B]class wildlife[/B]
{
public static void main(String[] args)
{
dog d=new dog();
lion l=new lion();
hippo h=new hippo;
vet v=new vet();
[COLOR="Red"]//what is happening after this line?[/COLOR]
v.cure(d);
v.cure(h);
}
}
should i learn it from an institute or i can do this at home?
PS:I know only C++,and that too not properly. Will that do?
Only if you don't have a computer.should i learn it from an institute
should i learn it from an institute or i can do this at home?
PS:I know only C++,and that too not properly. Will that do?
You can learn it from home, very well.
Don't get bothered about C++ knowledge. If you know OOP concepts from C++, it will be advantage for you(or easy, you can say).
PS:I know only C++,and that too not properly. Will that do?
class testing
{
public static int testprime(int num)
{
int flag=0;
for(int i=1;i<=num;i++)
{
if(num%i==0)
{
flag++;
}
}
if(flag>2)
return 0;
else
return 1;
}
public static void main(String args[])
{
int i,n=0,flag=0,t,x;
int p=2;
while(n<=10001)
{
x=n;
t=testprime(p);
if(t==1)
{
p++;
n++;
}
else
{
p++;
n=x;
}
}
}
}
wap to display in java based on the user input string where the input string is LAKSHMI
L
A A
K K K
S S S S
H H H
M M
I