|
-
Sep 29th, 2002, 11:15 PM
#1
Thread Starter
Addicted Member
I don't know what to name this topic
class X
{
public:
double A(double x)
{
return x*x;
}
double B(double x)
{
return A(x)/2;
}
};
class Y ublic X
{
public:
double A(double x)
{
return x*x*x;
}
};
void main()
{
Y y;
cout<<y.B(3);
}
this gives 4.5
but in java
public class X
{
public:
double A(double x)
{
return x*x;
}
double B(double x)
{
return A(x)/2;
}
}
public class Y extends X
{
public:
double A(double x)
{
return x*x*x;
}
}
public class App
{
public static void main(String s[])
{
Y y=new Y();
System.out.println(y.B(3));
}
}
this gives 13.5
Why
Then what is the use of interface in java?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|