77范文网 - 专业文章范例文档资料分享平台

《JAVA语言程序设计》期末考试复习资料(2)

来源:网络收集 时间:2019-03-11 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

int k = i;

for ( j = i ; j < a.length ; j++ )

if ( a[j]

}

for ( i =0 ; i

System.out.print(a[i]+\ \

System.out.println( ); } }

3.写出以下程序的功能。

import java.io.*; public class TestFile {

public static void main(String args[]) throws Exception {

BufferedReader br = new BufferedReader(

new InputStreamReader(System.in));

BufferedWriter bw = new BufferedWriter(new FileWriter(“input.txt\ String s; while (true)

{

System.out.print(\请输入一个字符串: \ System.out.flush(); s=br.readLine(); if (s.length()==0) break; bw.write(s); bw.newLine(); } bw.close(); }

}

功能:从键盘逐一输入字符串,逐一输出至input.txt文件中,直至输入空行。

4.阅读以下程序,写出输出结果。

class Animal { Animal() {

System.out.print (\ \ } }

public class Dog extends Animal { Dog() {

System.out.print (\ }

public static void main(String[] args) { Dog snoppy= new Dog(); } }

输出结果:Animal Dog

《JAVA语言程序设计》期末考试试题及答案3(应考

必备题库)

一、单项选择题

1、如下哪个是Java中的标识符( D )

A、public

4、如下哪个是Java中有效的关键字( C )

A、name

5、下面的代码段执行之后count的值是什么( D )

int count = 1;

for (int i = 1; i <= 5; i++) { }

System.out.println(count);

count += i;

B、super C、3number D、width

B、hello C、false D、good

A、5

B、1 C、15 D、16

6、定义一个类,必须使用的关键字是( B )

A、public

7、定义一个接口必须使用的关键字是( C )

A、public

B、class

C、interface

D、static

9、声明并创建一个按钮对象b,应该使用的语句是( A )

A、Button b=new Button(); B、button b=new button(); C、Button b=new b(); D、b.setLabel(“确定”);

10、Frame对象默认的布局管理器是( B )

A、FlowLayout C、CardLayout

11、以下程序段的输出结果是(三角形)

int x = 5, y = 6, z = 4;

if (x + y > z && x + z > y && z + y > x) System.out.println(\三角形\); else

System.out.println(\不是三角形\);

B、class C、interface D、static

B、BorderLayout D、null

12、下面程序段的执行结果是(6 5 4 3 2)

int a[] = { 2, 3, 4, 5, 6 };

for (int i = a.length - 1; i >= 0; i--)

System.out.print(a[i] + \);

三、程序阅读题

1、以下程序的输出结果为_ Peter is 17 years old!___。

public class Person { }

public static void main(String[] args) { }

Person c = new Person(\, 17);

System.out.println(c.name + \ + c.age + \); public Person(String name, int age) { }

this.name = name; this.age = age; String name; int age;

2、以下程序的输出结果为__课程号:101 课程名:ASP 学分:3___。

public class Course {

public void printCourseInfo() {

System.out.println(\课程号:\ + cNumber + \课程名:\ + cName + \学public Course(String number, String name, int unit) { }

cNumber = number; cName = name; cUnit = unit; private String cNumber; private String cName; private int cUnit;

分:\ + cUnit); } }

class CourseTest {

}

public static void main(String[] args) { }

Course c;

c = new Course(\, \, 3); c.printCourseInfo();

3、以下程序的输出结果为__汤姆猫体重:20.0斤___。

public class Tom { }

public static void main(String[] args) { }

Tom.name = \汤姆猫\; Tom cat = new Tom(); cat.setWeight(20); cat.out(); private void out() {

System.out.println(name + \体重:\ + weight + \斤\); }

public void setWeight(float weight) { }

this.weight = weight; private float weight; private static String name;

4、以下程序的输出结果_姓名:Tom 年龄:15 家庭住址:金水区 电话:66123456 学校:九中_。

public class Father {

void out() {

System.out.print(\姓名:\ + name); System.out.print(\年龄:\ + age); public Father(String name, int age) { }

this.name = name; this.age = age;

String name, address, tel; int age;

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库《JAVA语言程序设计》期末考试复习资料(2)在线全文阅读。

《JAVA语言程序设计》期末考试复习资料(2).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/516278.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: