java程序运行结果。。急!!
写出下面程序的运行结果1.importjava.io.*;publicclassabc{publicstaticvoidmain(Stringargs[]){SubCla...
写出下面程序的运行结果
1.import java.io.*;
public class abc
{
public static void main(String args[])
{
SubClass sb = new SubClass( );
System.out.println(sb.min( ));
}
}
class SuperClass
{
int a = 10 , b = 20 ;
}
class SubClass extends SuperClass
{
int min( )
{
return ((a<b)?a:b);
}
}
结果:
2.import java.awt.*;
import java.applet.Applet;
public class DrawMyImage extends Applet
{
Image myImage; // 定义一个图像类Image的对象myImage
public void init( )
{
myImage = getImage(getDocumentBase( ),"pica.jpg");
}
public void paint(Graphics g)
{
g.drawImage(myImage,0,0,this);
}
结果:
3. import java.io.*;
public class abc
{
public static void main(String args[])
{
String s1 = "Hello!";
String s2 = new String("World!");
System.out.println(s1.concat(s2));
}
}
结果:
4.import java.io.*;
class Parent
{
void printMe()
{
System.out.println("parent");
}
}
class Child extends Parent
{
void printMe()
{
System.out.println("child");
}
void printAll()
{
super.printMe();
this.printMe();
printMe();
}
}
public class Class1
{
public static void main(String args[ ])
{
Child myC = new Child( );
myC.printAll( );
}
}
结果:
5. import java.io.* ;
public class abc
{
public static void main(String args[ ])
{ SubSubClass x = new SubSubClass(10 , 20 , 30);
x.show();
}
}
class SuperClass
{ int a,b;
SuperClass(int aa , int bb)
{ a=aa; b=bb; }
void show( )
{ System.out.println("a="+a+"\\nb="+b); }
}
class SubClass extends SuperClass
{ int c;
SubClass(int aa,int bb,int cc)
{ super(aa,bb);
c=cc;
}
}
class SubSubClass extends SubClass
{ int a;
SubSubClass(int aa,int bb,int cc)
{ super(aa,bb,cc);
a=aa+bb+cc;
}
void show()
{ System.out.println("a="+a+"\\nb="+b+"\\nc="+c); }
}
结果: 展开
1.import java.io.*;
public class abc
{
public static void main(String args[])
{
SubClass sb = new SubClass( );
System.out.println(sb.min( ));
}
}
class SuperClass
{
int a = 10 , b = 20 ;
}
class SubClass extends SuperClass
{
int min( )
{
return ((a<b)?a:b);
}
}
结果:
2.import java.awt.*;
import java.applet.Applet;
public class DrawMyImage extends Applet
{
Image myImage; // 定义一个图像类Image的对象myImage
public void init( )
{
myImage = getImage(getDocumentBase( ),"pica.jpg");
}
public void paint(Graphics g)
{
g.drawImage(myImage,0,0,this);
}
结果:
3. import java.io.*;
public class abc
{
public static void main(String args[])
{
String s1 = "Hello!";
String s2 = new String("World!");
System.out.println(s1.concat(s2));
}
}
结果:
4.import java.io.*;
class Parent
{
void printMe()
{
System.out.println("parent");
}
}
class Child extends Parent
{
void printMe()
{
System.out.println("child");
}
void printAll()
{
super.printMe();
this.printMe();
printMe();
}
}
public class Class1
{
public static void main(String args[ ])
{
Child myC = new Child( );
myC.printAll( );
}
}
结果:
5. import java.io.* ;
public class abc
{
public static void main(String args[ ])
{ SubSubClass x = new SubSubClass(10 , 20 , 30);
x.show();
}
}
class SuperClass
{ int a,b;
SuperClass(int aa , int bb)
{ a=aa; b=bb; }
void show( )
{ System.out.println("a="+a+"\\nb="+b); }
}
class SubClass extends SuperClass
{ int c;
SubClass(int aa,int bb,int cc)
{ super(aa,bb);
c=cc;
}
}
class SubSubClass extends SubClass
{ int a;
SubSubClass(int aa,int bb,int cc)
{ super(aa,bb,cc);
a=aa+bb+cc;
}
void show()
{ System.out.println("a="+a+"\\nb="+b+"\\nc="+c); }
}
结果: 展开
4个回答
展开全部
你下个eclipse自己运行不就OK了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1。10
3.Hello!World!
4 parent child child
5.60 20 30
3.Hello!World!
4 parent child child
5.60 20 30
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼主真懒,我都知道,就是不告诉你!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
自己动手,丰衣足食
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询