posts - 78,  comments - 48,  trackbacks - 0
最近发现自己很多基础问题都不明白。导出搜集。于是有这一贴:
题目:
1.java程序在保存文件时,后缀名是?
2.java程序经过编译过后,后缀名是?
3.java程序文件保存时,主文件名是?
4.如何用浏览器观看输出至命令行模式的结果?
5.如何把一个java applet放到网页上?
6.public class  cjc extends java.applet.Applet{
public static void main(String args[])
{
cjc mf=new cjc();
mf.init();
}
public void init(){
累加 累加数字 = new 累加(10);
System.out.println(累加数字.总和());
}
}
class 累加{
int in=;
public 累加(int in){
this.in=in;
}
public int 总和(){
int i,sum;
sum=0;for(i=1;i<=in;i++)  sum+=i;
return sum;
}
}
如果你想要计算a加到b的总和,如何修改?
题目:
1. 下面哪个是对的?
A.IloveJava     B.$20   C.piggy@msl    D.Hello_worle   E.2two     F.sum+of+money
2.下面可能产生什么结果?如果有错如何改正?
int i=5;
int j=2;
k=i*j;
3.下面可能产生什么结果?如果有错如何改正?
float f=2.5;
f=f*2;
4.answer变量的数据类型应该是?
byte b=1;     char c=2;    short s=3;    int i=4;     float f=5.0f;
answer=b*c*s*i*f;
5.如果我想要把[2*2.5]的结果用一个float变量存放的话,程序应该如何编写?
题目:
1.请问最后a,b变量的数值是?
int x,a=5,b3;      x=a++ + b--;
A.x=8,a=5,b=3;    B.x=8,a=6,b=2;     C.x=7,a=5,b=2;     D.x=9,a=6,b=3;
2.下列表达式,哪几个是正确的?
A.int x=6;x=!x;     B.int x=6;x=~x;   C.boolean b=true; b=!b;    D. boolean b=true; b=!b;
3.下列表达式,哪几个x变量的值最后会是正数?
A.int x=-1;x=x>>>5;    B.int x=-1;x=x>>>32;     C.byte x=-1;x=x>>>5;  
D.int x=-1;x=x>>5;
4.下列的变量x,y,哪几个运算完,结果使true?
A.int i=100;float f=500.0f;i==f?     B.int i=40;float f=500.0f;i>f?
C.int i=20;float f=30.0f;i<f?           D.int i=55;float f=33.3f;i!=f?
5.下列的结果是?
int i=100;     i=((i++>>35) << 32)%10;
A.0     B.1     C.2      D.3

题目:
1.if(score >=90 && score <=100)
finalScore="甲";
else if (score >=80 && score <=90)
finalScore="乙 ";
else if (score >=70 && score <=80)
finalScore="丙 ";
else if (score >=60 && score <=70)
finalScore="丁 ";
else
finalScore="戊 ";
用更简单的方法写出来(不能用逻辑表达式)
2.写一个程序,它能够计算a加到b的总和,其中a不一定比b小。
3.写一个程序,它能够把1到100中的质数显示出来。
4.写一个程序,能够从五个数字中跳出最大值。
5.那些循环语句的写法是正确的?
A.while (int i<5){ i++; System.out.println(i);}
B.int i=5; while(i)  System.out.println(i);
C.int j=1; for (int k=1;j+k != 10;j++,k++)    System.out.println("j="+j+"k="+k);
D.int j=1;  do { System.out.println(j++);   if(j==5) contine loop1;}   while (j<20);

题目:
1.哪些是合法的重载?
public class Q1{      public void method(int i){ };     }
A.private void method(int i){ }           B.public void method(int k){ }
C.public int method(int i){ }               D.private float method(float f){ }
E.public String method(int i,int j){ }
2. 在Q2_2类中,哪些是合法的覆盖?
public class Q2_1{
public void method(int i){ };
}
class Q2_2 extends Q2_1{
}
A.public void method(int i){ }              B.private void method(int j){ }
C.public int method(int i){ }                D.public float method(float f){ }
E.private String method(String s){ }
3.Q4_2类运行的结果是什么?为什么?若把Q4_2类的第9行改成 Q4_1 q2=new Q4_2();  结果是多少?为什么?若把第11行改成 ((Q4_2) q2).method(); 结果是多少?为什么?
01:        public class Q4_1{
02:        public void method(int i){
03:        System.out.println(10);
04:}
05:}
06:        public class Q4_2 extends Q4_1{
07:        public static void main(String args{}){
08:        Q4_1 q1=new Q4_1();      
09:        Q4_2 q2=new Q4_2();
010:      q1.method(1);    
011:   q2.method(2);
012:}
013:      public void method(int k){
014:      System.out.println(20);
015:}

4.在Q9_1类中应该有哪些构造函数?
public class Q9_2 extends Q9_1{
public Q9_2(int i){ }
public Q9_2(int i,float f){ super(i,f)}
}
A.public Q9_1(){ }                                      B.public Q9_1(int k){ }
C.public Q9_1(int i,float f){ }                      D.public Q9_1(float f){ }

题目:
1.错在哪里?
public class text{
public static void main(String args[]){
A a=new A();
B b=(B) a;
C c=new A();
D d=(D) c;
}
}
class A{}
class B extends A {}
class C extends B {}
class D extends A {}
2.若一个抽象类种所有的方法都是抽象方法时,是不是可以改为接口?

1.两个对象作比较运算时,使用==运算符和equals方法有什么差别?
2.如果让一个类有复制能力,应该用那个接口?
3.如何把一个对象用字符串表示出来?
4.设计一个三角形和矩形类,修改它们的equals方法,如果两个对象面积相同,则equals方法返回true

1.如果有个int[0]型的数组x,你觉得A、B两种循环写法,哪一种比较好?为什么?
A.for(int i=1;i<10;i++)            B.for(int i=0;i<x.length;i++)
2.对象内存回收的顺序和什么有关?
3.可不可以控制何时启动GC?

try{
FileInputStream f=FileInputStream("test.txt");
System.out.println("Open file successed!");
}
catch(FileNotException fe){
System.out.println("File not found!");
}
catch(IOException ie){
System.out.println("IO  exception!");
}
catch(Exception e){
System.out.println("General  Exception!");
}
finally{
System.out.println("Do finally block!");
}
System.out.println("out of try block!");
1.如果第2行代码在运行时出现异常,程序会输出什么结果?
A.Open file successed!                                    B.File not found!
C.IO  exception!                                              D.General  Exception!
E.Do finally block!                                            F.out of try block!
2.接第一题,.如果第2行代码在运行时没有出现异常,程序会输出什么结果?
3.接第一题,.如果代码在运行时出现OutOfMemoryError异常,程序会输出什么结果?
4.f是个File类对象,它有个方法exists,用来检查文件是否存在。下面那一段代码最合适?
A.Exception e=new IOException("File not found!");
if(!exists)
throw e;
B.if(!exists)
throw new IOException("File"+f.getName()+" not found!");
C.if(!exists)
throw new IOException;
D..if(!exists)
throw "File not found!";
E.if(!exists)
throw new IOException();

1.说明Frame使用pack何setSize这两个方法的差别。
2.使用GridBagLayout时,需要设置那几种属性。
3.用GridBagLayout来模拟BorderLayout.
4.用java程学设计出如下的GUI界面。(组建可以设用Button类)
posted on 2006-03-27 16:49 黑咖啡 阅读(441) 评论(0)  编辑  收藏 所属分类: Java Dev

只有注册用户登录后才能发表评论。


网站导航:
 

<2006年3月>
2627281234
567891011
12131415161718
19202122232425
2627282930311
2345678

留言簿(2)

随笔分类(67)

文章分类(43)

Good Article

Good Blogs

Open Source

最新随笔

最新评论

阅读排行榜

评论排行榜