Java东华理工大学试卷A
更新时间:2023-09-03 23:49:01 阅读量: 教育文库 文档下载
大学2012 —2013 学年第 1 学期考试试卷
闭 课程类别:考查 A
b = false || true ;
System.out.println("b = "+b); } } What is the result?( )
A、b=false b=true B、b=true b= false C、b=true b= true D、b= false b= false 6. class example {
public static void main(String args[]) {
int i=1; a[i++]=a[i++]+2; System.out.println(a[i++]); }} What is the result?( )
A, 4 B, 5 C 3, D,6 7.public class Example{ String str=new String("good"); char[]ch={'a','b','c'};
public static void main(String args[]){ Example ex=new Example(); ex.change(ex.str,ex.ch); System.out.print(ex.str+" and ");
1 选择题(共35分)
1.What is suffix(后缀) of Java source code?( )? A、 .java B、.class C、.txt D、.ext 2. Which command can compile Java source code? ( )? A、 edit B、 dir C、 java D、javac 3. Which identifies is illegal ( )?
A、$_$123 B、_something C、some**name D、you_can_al 4. Which conversion (转换) is illegal ( )?
A、short x=1000; B、byte x=1000; C、byte x=100; D、float x=12L; 5.class example {
public static void main(String args[]) { boolean b;
b = (2 > 3) && (3 < 2); System.out.print("b = "+b);
专用考试纸 请勿浪费 卷 第1页 共9页
Sytem.out.print(ex.ch); }
public void change(String str,char ch[]){ str="test ok";
ch[0]='g'; } } What is the result?( )
A good and abc B good and gbc C test ok and abc D test ok and gbc
5. if(s1.equals(b1)){
6. System.out.println(“equal”);}}} A the program runs and prints nothing B the program runs and prints “equal” C An error at line 5 causes compilation to fail D The program runs but aborts with an exception
8. Set x=1,y=2,z=3, expression :y+=z--/++x what is result ( ) A 3 B 3.5 C 4 D 5
11.1.interface A{
9. what is result ( )?
2. int a=3;
class example{
3. void show();
static int a=3;
4.}
public static void main(String args[]){
5.class B implement A{
new example().a++;
6. void show(){}
new example().a+=2;
7.public static void main(String args[]){
System.out.println(example.a);}}
8. System.out.println(a++);}}
A 6 B 7 C 4 D 5
Which lines are incorrect when the code is compiled?( )
10. 1.class X{
A 5 7 B 6 8 C 5 6 8 D 5 6
2.public static void main(String args[]){
12 class A{
3. String s1=new String(“true”);
int a=2;}
4. Boolean b1=new Boolean(true);
class B extends A{
专用考试纸 请勿浪费 卷 第2页 共9页
int a=3;} class test{
public static void main(String args[]){ A g=new B();
System.out.println(g.a);}}What is result? ( ) A 2 B no result C 1 D 3 13 what is result ( ) class A{
public static void main(String args[]){ try{ int a=1/0; int []b={1,2}; b[4]=4; }
catch(ArrayIndexOutOfBoundsException e){ System.out.print("vvv"); }
catch(ArithmeticException e){ System.out.print("rrr"); }
finally{
System.out.println("sss"); } } }
A rrrvvv B rrrsss C vvvsss D sssrrr 14. class A{
final int i4=(int)(Math.random()*20); static final int i5=(int)(Math.random()*20); public void print(){
System.out.println("i4="+i4+"i5="+i5);} public static void main(String args[]){ A g1= new A(); g1.print(); A g2= new A(); g2.print(); }}
Assume i4=15 i5=16 when g1.print() method is executed . what result is displayed when g2.print() is executed( )
A 15 16 B 15 17 C 18 14 D 15 15 15.class A{
void f(int x){System.out.println(x);}
专用考试纸 请勿浪费 卷 第3页 共9页
void f(long x){System.out.println(x);} public static void main(String args[]) { A g1= new A(); g1.f(5.6); }} What is result( )
A 5.6 B 5 C 6 D error 二、翻译题20分,每小题5分
1)Encapsulation is the mechanism that binds together code and the data it manipulates, and keep both safe from outside interference and misuse.
2)Encapsulation allows an object to separate its interface from its implementation. The data and the implementation code for the object
are hidden behind its interface. So encapsulation hides internal implementation details from users. The power of encapsulated code is that everyone knows how to access it and thus can use it regardless of the implementation details and without fear of unexpected side effects.
3)In Java the basis of encapsulation is the class. A class defines the structure and behavior (data and code) that will be shared by a set of
专用考试纸 请勿浪费 卷 第4页 共9页
defined by the class, as if it were stamped out by a mold in the shape of the class. For this reason, objects are sometimes referred to as instance of class. Thus, a class is a logical construct; an object has physical reality.
4)When you create a class, you will specify the code and data that constitute that class. Collectively, these elements are called members of the class. Specifically the code that operates on that data is referred to as member variables or instance variables.
三 程序阅读题(每题4分,共计20分):
The result of following program is:_________________________ import java.io.*; public class UseLabel
{ public static void main(String[] args) {
Loop:
专用考试纸 请勿浪费 卷 第5页 共9页
} } }
The result of following program is: _________________________ import java.io.*; public class Class1 {
public static void main(String args[]){
int i,ax,in;
int a[] = {12,67,8,98,23,56,124,55,99,100); ax= in= a[0];
for(i=1; i<a.length; i++){ }
if( a[i]< in) in = a[i]; if( a[i]> ax) ax = a[i];
for(int i=2; i<10; i++) { for(int j=2;j<i;j++)
if( i%j == 0) continue Loop; System.out.print(i+" ");
System.out.println( ax + " " + in); System.out.println();
} }
The result of following program is: _________________________ class A { int a; A(){ a=1 ;} A(int b) {a=b;} void show() {
System.out.println(“a=”+a);} }
public class Class1 {
public static void main (String args[]) {
专用考试纸 请勿浪费 卷 第6页 共9页
A a1=new A(12); A a2=new A(); a1.show(); a2.show(); boolean b=false; char ch=65;
System.out.println(“b=”+b+”\tch=”+ch); } }
The result of following program is: _________________________ class A{ }
class B extends A{ int x; int x; void print(){ }
System.out.println("x in A:"+x);
}
public class HideFields {
public static void main(String[] args) { B b=new B(); void output(){ } x=32; super.x=54; print();
System.out.println("x is B:"+x);
b.output(); }
The result of following program is: _________________________
public class ArithmeticException {
public static void main(String args[]){
int a,b,c; }
专用考试纸 请勿浪费 卷 第7页 共9页
} }
System.out.println("java程序运行结束! "); try{ a=9; b=0; c=a/b;
System.out.println(a+"/"+b+"="+c);
四、编程题25分
1.Write a program which cast one integer to byte, one double to int and one double to byte..(10分)
专用考试纸 请勿浪费 卷 第8页 共9页
}catch(ArithmeticException e){
System.out.println("出现被0除的异常情况");
} finally{ }
System.out.println("除数="+a); System.out.println("被除数="+b);
、Write a program that print all strings which consists of 1 , 3 , 5 , 8 , 9 .(输出由字符1,3,5,8,9组成的所有可能字符串)(15分)
专用考试纸 请勿浪费 卷 第9页 共9页
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 东华
- 试卷
- 理工
- 大学
- Java
- 【精品】人教版四年级数学上册电子教案设计:第3课时_田忌赛马
- LNG(液化天然气)客车的使用及维修注意事项
- 症状自评量表SCL90
- 微电解填料【信息】
- 渣打Talent Q- Logic
- 习作一 美丽的校园
- 企业会计准则解释第4号
- Win8 Win7双系统安装图文教程
- 小学一年级体育最新教案(表格式共18页)
- 2015-2016年河北省保定市高三上学期期末数学试卷(文科)及答案WORD版
- (目录)2018-2023年中国智能眼镜行业市场深度分析与投资前景预测研究报告
- 幼儿发展观察评析记录表
- 公司收款收据
- 人教版八年级生物《真菌》
- 国家级实验教学示范中心
- 教科版高中物理选修3-4第2节 实验探究:测定玻璃的折射率
- 华尔街观后感
- 十三五重点项目-1000亩无公害蔬菜基地项目资金申请报告
- 【高中数学必修四】1.4.3正切函数的图象和性质
- 博士论文开题报告-文献综述