class A{
String str;
private int n = 123456;
public A(String str){
this.str = str;
}
public int getn(){
return n;
}
}class B extends A{
float x;
public B(String str, float x){
super.str = str;
this.x = x;
}
}public class Class1{
boolean bool = true;
B b;
public static void main(String[] args){
b = new b('java', 12345.6);
System.println("str = " + b.str);
System.println("n = " + b.getn());
System.println("x = " + b.x);
System.println("bool = " + b.bool); }
}
String str;
private int n = 123456;
public A(String str){
this.str = str;
}
public int getn(){
return n;
}
}class B extends A{
float x;
public B(String str, float x){
super.str = str;
this.x = x;
}
}public class Class1{
boolean bool = true;
B b;
public static void main(String[] args){
b = new b('java', 12345.6);
System.println("str = " + b.str);
System.println("n = " + b.getn());
System.println("x = " + b.x);
System.println("bool = " + b.bool); }
}
解决方案 »
- 求一个用JAVA GUI+MYSQL数据库做的简单的成绩管理系统
- 请教如何利用ANT标识系统版本号的问题!
- 怎样通过网页来运行java的servlet.class程序,谢,在线等待...(初学java)
- 我将JPanel对象放在了屏幕的底端,但是却无法调整它的大小,请高手解答
- 如何恰当地获得已运行时间
- 求高手点拨一个“Socket通信”中的问题.
- 为什么一运行就错误啊?
- 修改后没效果
- 我对抽象的理解
- 新手在线等解决,急!Exception in thread "main" java.lang.NullPointerException
- 多线程问题--请帮我看一下我写的一个代码!
- 画图每次自动刷屏,怎么回事?前辈请指点!急急,在线等待!!
public String str;
private int n = 123456;
public A(){ } public A(String strA) {
str = strA;
} public int getn() {
return n;
}
};class B
extends A {
float x;
public B(String strB, float fValue) {
str = strB;
x = fValue;
}
};class Calss1 {
public static void main(String[] args) {
boolean bool = true;
float dddd = 12345.6f;
B b = new B("java", dddd);
System.out.println("str=" + b.str + ";n=" + b.getn() + ";x=" + b.x +
";bool:=" + bool);
}
}
public String str;
private int n=123456;
public A(){}
public A(String strA){
str=strA;
}
public int getn(){
return n;
}
}
class B extends A{
float x;
public B(String strB,float xB){
str=strB;
x=xB;
}
}
public class Class1{
static boolean bool=true;
public static void main(String args[]){
B b=new B("java",12345.6f);
System.out.println("str: "+b.str);
System.out.println("n: "+b.getn());
System.out.println("x: "+b.x);
System.out.println("bool: "+bool);
}
}