java 08d_JAVA基础知识

《JAVA基础知识》由会员分享,可在线阅读,更多相关《JAVA基础知识(11页珍藏版)》请在人人文库网上搜索。

1、JAVA基础知识(每题2分,共72 分)C. *poi ntD. thisE. _en dli ne3. 下面的哪些程序片断可能导致错误A. Stri ng s = Gone with the wi nd; Stri ng t = good ; Stri ng k = s + t;C. String s = Gone with the wind;String sta ndard = s.toUpperCase();B. Stri ng s = Gone with the wi nd;Stri ng t;t = s3 + on e;D. Stri ng s = home directory;St。

2、ring t = s - directory;4. 在/ point x处的哪些申明在句法上合法的class Pers on private int a;public int cha nge(i nt m) retur n m; public class Teacher exte nds Person public int b;public static void main(String arg)Pers on p = new Pers on();Teacher t = new Teacher();int i;/ point xA. i = m;B. i = b;C. i = p.a;D. i。

3、 = p.cha nge(30);E. i = t.b.5. 给出下面的代码片断:2) Vector myVect;3) myVect = new Vector();4) 下面的哪些陈述为true(真)?A. 第二行的声明不会为变量myVect分配内存空间。B. 第二行的声明分配一个到Vector对象的引用的内存空间。C. 第二行语句创建一个Vector类对象。D. 第三行语句创建一个Vector类对象。一、多选题。根据问题,选择正确的答案。1. 下面哪些是合法的标识符?A. $pers onsB. TwoUsers2. 哪些是将一个十六进制值赋值给一个long型变量?A. long numb。

4、er = 345L;B. lo ng number = 0345;C. lo ng number = 0345L;D. lo ng number = 0x345LE. 第三行语句为一个 Vector 类对象分配内存空间。6. 下面的哪些答案可以用以表示八进制值 8?A. 010 B. 0x10 C. 08D. 0x87. 下列哪些不是 Java 关键字 ?A. TRUE B. sizeofC. const D. superE. void8. 下面关于继承的哪些叙述是正确的 ?A. 在java中只允许单一继承。B. 在java中abstract 类只能被继承。C. 在java中final类只能被。

5、继承。D. java 的单一继承使代码更可靠。9. 给出下列程序代码:1) class Person 2) public void prin tValue(i nt i, i nt j) /*/ 3) public void printValue(int i)/*.*/ 4) 5) public class Teacher extends Person 6) public void printValue() /*.*/ 7) public void printValue(int i) /*.*/8) public static void main(String args)9) Person t。

6、 = new Teacher();10) t.printValue(10);11) 12) 第十行的声明将调用哪些方法 ?C. on line 6D. on line 7A. on line 2 B. on line 310. 下面哪些不是 java 的原始数据类型 ?A. short B. Boolean C. unit D. float11. main() 方法的返回类型是什么?A. int B. void C. boolean D. static12. 给出下面的代码:if (x0) System.out.println(first); else if (x-3) System.out.。

7、println(second); else System.out.println(third); 问: x 的取值在什么范围内时将打印字符串 second?A. x 0 B. x -3 C. x -313. 下面的哪些赋值语句是不正确的A. float f = 11.1;C. double d = 3.14159;B. double d = 5.3E12;D. double d = 3.14D.11 / 9处?14. 给出下面的不完整的类代码: class Person String name, department; int age; public Person(String n) name。

8、 = n; public Person(String n, int a) name = n; age = a; public Person(String n, String d, int a) / doing the same as two arguments version of constructor / including assignment name=n,age=a department = d; 问:下面的哪些表达式可以加到构造方法中的 doing the same as. A. Person(n,a); B. this(Person(n,a);C. this(n,a) ;D. t。

9、his(name,age)15. 下面关于变量及其范围的陈述哪些是对的 ?A. 实例变量是类的成员变量。B. 实例变量用关键字 static 声明。C. 在方法中定义的局部变量在该方法被执行时创建D. 局部变量在使用前必须被初始化。16. 给出下面的代码: public class Test void printValue(int m) do System.out.println(The value is+m); while( -m 10 ) public static void main(String arg) int i=10;Test t= new Test(); t.printValu。

10、e(i); 问:输出将是什么?A. The value is 8 B. The value is 9C. The value is 10 D. The value is 1117. 下面的有关声明的哪些叙述是对的 ?A.对原始数据类型例如boolean,byte的变量的声明不会为该变量分配内存空间B.对原始数据类型例如boolean,byte的变量的声明将为之分配内存空间。C.非原始数据类型例如String,Vector的变量的声明不会为该对象分配内存。D.非原始数据类型例如String,Vector的变量的声明会为该对象分配内存。18. 给出下面的代码:1) public void modi。

11、fy() 2) int i, j, k;3) i = 100;4) while ( i 0 ) 5) j = i * 2;6) System.out.println ( The value of j is + j );7) k = k + 1;8) i-;9) 10) 问:哪些行在编译时可能产生错误 ?D. line 8A. line 4 B. line 6 C. line 719. 下面有关变量及其作用域的陈述哪些是对的 ?A. 在方法里面定义的局部变量在方法退出的时候被撤销。B. 局部变量也叫自动变量。C. 在方法外面定义的变量(译注:即实例变量)在对象被构造时创建D. 在方法中定义的方法。

12、的参变量只要该对象被需要就一直存在。20. 类的设计要求它的某个成员变量不能被外部类直接访问。应该使用下面的哪些 修饰符获得需要的访问控制 ?A. public B. no modifier C. protected D. private21. 下列哪个类声明是正确的? A. abstract final class HI C.protected private number;B.abstract private move()D.public abstract class Car22. 给出下面的程序代码片段: public class Base int w, x, y ,z;public B。

13、ase(int a,int b) x=a; y=b;public Base(int a, int b, int c, int d) / assignment x=a, y=bw=d;z=c;:下面的哪些表达式可以加到构造方法中注释的 / assignment x=a, y=b? 处? Base(a,b); B. x=a, y=b; C. x=a; y=b; D. this(a,b);23. 给出下列定义:String s = story; 问:下面的哪些表达式哪些是合法的 l?C. int len = s.length; D. String t =A. s += books; B. char 。

14、c = s1; s.toLowerCase();24. 执行下列程序段后, i 和 j 的返回值是什么?int i = 1;int j;j = i+;A. 1, 1B. 1, 2C. 2, 1D. 2, 225下面哪些是 Java 的有效标识符?A. fieldname B. super C. 3number D. #number E. $number 26作为 main() 方法中的参数列表,下列中哪些是正确的?A. char args B. char args C. String arg D. String args E. String args27根据表达式:int m = 0, 1, 。

15、2, 3, 4, 5, 6 ;能够确定数据元素个数的表达式是哪些?A. m.length() B. m.length C. m.length()+1 D. m.length+128给出下列程序代码:public class Testlong a = new long10;public static void main ( String arg ) System.out.println ( a6 );问下面的语句哪些是正确的?A.输出是null。 . B.输出是0。 C.编译时出错。D.运行时出错。29给出下列程序代码段:public class Testpublic static void m。

16、ain(String arg)int i = 5;do System.out.println(i); while (-i5)System.out.println(Finished);程序执行后输出的结果是什么 ?A. 5 B. 4 C. 6 D. Finished E. None30给出下列程序代码:switch (m)case 0: System.out.println(Condition 0);case 1: System.out.println(Condition 1);case 2: System.out.println(Condition 2);case 3: System.out.。

17、println(Condition 3);break;default: System.out.println(Other Condition);问:当 m 取何值时可以输出 Condition 2?A. 0 B. 1 C. 2 D. 3 E. 4 F. None31哪些是 Java 的合法限定符 ?A. private B. public C. protected D. protect E. friend32 哪些是定义成员变量常量的修饰符 ?A. static B. final C. abstract D. No modifier can be used33下面程序代码定义了一个类:publ。

18、ic class Test private float f = 1.0;int m = 12;static int n=1;public static void main(String arg) Test t = new Test();/ some code. 问下面的用法哪些是合法的 ?A. t.f B. this.n C. Test.m D. Test.n34给出下面程序代码:Given the following class definition in one source file:class Base public Base () /. public Base ( int m ) /。

19、. protected void fun( int n ) /.public class Child exte nds Base/ member methods问下面的哪些方法可以添加到子类中A. private void fun( int n ) /.C. protected void fun ( int n ) /. E. public m() /. 35 .若Jjava的源文件名为 Test.java,A. public class test public int x = 0;public test(i nt x)this.x = x;C. public class Test exte 。

20、nds T1, T2 public int x = 0;public Test (i nt x) this.x = x;E. protected class Test exte nds T2 public int x=0;public Test(i nt x)this.x=x;36.给出程序代码如下:public class Parent int cha nge() class Child exte nds Parent 问哪些方法可被加入类Child?A. public int cha nge()B. int chang(int i)C. private int cha nge()B. vo。

21、id fun ( int n ) /. D. public void fun ( int n ) /. F面关于类的定义哪些是正确的B. public class Test public int x=0;public Test(i nt x) this.x = x;D. public class Test exte nds T1 public int x=0;public Test(i nt x)this.x = x;D. abstract int cha ng()二、判断题(每题 1分,共 8 分)1. 抽象类中一定有抽象方法。()2. 子类与超类具有一样的功能。()3. 抽象方法只能在其所在类的子类中通过方法覆盖面具体实现。()4. JAVA 语言允许多重继承。()5. FINAL 类可以有多个子类。()6 .把一个类型强制转换成另一个类型的过程称作造型。()7. 含有抽象抽象方法的类一定是抽象类。()8. 抽象类可以实例化对象。()三、简答题(每题 4分,共 20 分)1.简述JAVA中类的构成要素?2 .简述JAVA中构造器的定义及功能?3. 简述类变量与类方法的调用方法?4.OOP 中对象的基本特征是什么?5.简述数据封装的意义是什么。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值