ImageVerifierCode 换一换
格式:DOCX , 页数:22 ,大小:29.72KB ,
资源ID:9090402      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/9090402.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(java资料.docx)为本站会员(b****7)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

java资料.docx

1、java资料第1章Java语言基础一. 概念复习和巩固(请在课后和上机前完成下面的练习)1.下面说法正确的是( C )。A)Java 程序的源文件名称与主类(公共类)的名称相同,后缀可以是java或txt等。 B)JDK的编译命令是java。C)一个java源程序编译后可能产生几个字节码文件。D)在命令行运行编译好的字节码文件,只需在命令行直接键入程序名即可运行该程序。2.下面的说法正确的是(ABCD)。A) Java 语言是面向对象的、解释执行的网络编程语言。B) Java 语言具有可移植性,是与平台无关的编程语言。 C) Java 语言可对内存垃圾自动收集。 D) Java 语言编写的程序

2、虽然是“一次编译,到处运行”,但必须要java的运行环境。3.下面main()方法的定义哪些是正确的(ACD)?A)public static void main(String args) B)public static void main(String) C)public static void main(String args) D)public static void main(String x) 4.用于定义数据简单类型的一组关键字是(B)。A) class, float, main, publicB) float, boolean, int, longC) char, extends

3、, float, doubleD) int, long, float, import5.以下的变量定义中,合法的语句是(B)。A) float 1_variable = 3.4; B) int abc_ = 21;C) double a = 1 + 4e2.5; D) short do = 15;6.定义变量如下: int i=18; long L=5; float f=9.8f; double d=1.2; String s=123; 以下赋值语句正确的是(ABD)。A) s=s+i; B) f=L+i; C) L=f+i; D) s=s+i+f+d; 7.以下语句输出的结果是( A Str

4、ing str=123; int x=4,y=5; str=str+(x+y); System.out.println(str);A)1239 B)12345 C)会产生编译错误 D)123+4+58.以下语句中没有编译错误或警告提示信息的是(B)?A)byte b=256; B)double d=89L; C)char c=a; D)short s=8.6f;9. 下面的程序输出结果是:1+2=3,请将程序补充完整。public class App2 public static void main(String args) int x=1,y=2; System.out.println(_)

5、; 答案:x+y+=+(x+y)10.阅读下面的程序,回答问题。程序如下:public class App1 public static void main(String args) char ch=n; System.out.print(The first snow came,+ch+How beautiful it was!); (1)这是哪一类java程序?(2)写出保存该文件的文件名及后缀名?(3)在JDK下编译该文件的命令是什么?编译后形成什么文件?(4)在JDK下如何运行该程序?程序运行后输出的结果如何?10.答案:(1)Java应用程序(Java Application);(2)

6、App1.java;(3)在命令行用javac App1.java编译该程序。 编译后形成App1.class的字节码文件;(4)在命令行键入java App1即可运行该程序。 编程序运行后输出的结果为: The first snow came, How beautiful it was!11.阅读下面的程序,回答问题。import java.applet.Applet;import java.awt.Graphics;public class Applet1 extends Applet public void paint (Graphics g) g.drawString (Welcome

7、,25,30); g.drawString (to,85,30); g.drawString (Java,25,50); g.drawString (Programming!,55,50); (1)这是哪一类java程序?(2)写出保存该文件的文件名及后缀名?(3)在JDK下编译该文件的命令是什么?编译后形成什么文件?(4)该程序能直接运行吗?写出嵌入该程序的字节码文件的html文件,该html文件可以任意命名吗?(5)程序运行后输出几行?写出输出结果。11.答案:(1) Java小程序(Java Applet)。 (2)Applet1.java(3)在命令行用javac Applet1.ja

8、va编译该程序。编译后形成Applet1.class的字节码文件。(4)不能,为了能使程序运行,还需编写html文件,用标记符将编译形成的字节码文件嵌入到html文件中,然后通过浏览器运行Java Applet。或在命令行通过命令appletviewer 运行html文件。嵌入该程序的字节码文件的html文件如下,该html文件可以任意命名(如命名为mypage.htm)mypage.htm文件如下:我的网页(5)程序运行后输出2行;输出结果如下:第2章 使用Java解决简单的问题一. 概念复习和巩固(请在课后和上机前完成下面的练习)1.以下选项中变量均已正确定义,错误的赋值语句是(D)。A)

9、 i-; B) i += 7; C) k += x +2; D) y + x = z; 2.若以下变量均已正确定义并赋值,下面符合Java语言语法的表达式是(B)。A) a = a7 B) a = 7 + b + cC) int 12.3 % 4 D) a = a + 7 = c + b3.定义整型变量: int n=456;,表达式的值为5的是(AB)。A) n / 10 % 10 B) ( n - n / 100 * 100 )/10C) n % 10 D) n / 104.对下面的语句序列正确的说法是 (B)。int c=A/3;c+=1%5; System.out.println(c)

10、;A)产生编译错误; B)输出结果25;C)输出结果21; D)输出结果2;5.设 a, f, x, y, z 均为 int 型的变量,并已赋值,下列表达式的结果属于非逻辑值的是(D)。A) x y & f a B) -z x - yC) y != +x D) y + x * x+6.执行下列程序段后,b, x, y的值正确的是(C)。 int x=6,y=8; boolean b; b=xy|+x=-y;A) true , 6, 8 B) false , 7, 7C) true, 7, 7 D) false, 6, 87.下面的程序段输出的变量b的值是(B )。int a = 0xFFFFF

11、FFE;int b= a; System.out.println(b=+b);A) 0xFFFFFFFE B) 1 C) 14 D)-28.若a和b均是整型变量并已正确赋值,正确的switch语句是(A)。A) switch(a+b); B) switch( a+b*3.0 ) C) switch a D) switch ( a%b ) 9.以下由do-while语句构成的循环执行的次数是(D)。 A)无限次 B)有语法错,不能执行 C)一次也不执行 D)执行1次 int k = 0;do +k; while ( k 1 );10. 执行完下面的程序段后,k的值是(B)。int k=0; la

12、bel:for(int i=1;i10;i+) for(int j=1;j5;j+) k+=i+j; if(j=3) break label; A) 3 B) 9 C)12 D) 611.下列方法x的定义中,正确的是(A)。A) int x( ) char ch=a; return (int)ch; B) void x . C) int x( int i ) return (double)(i+10); D) x( int a) return a; 12.下列方法定义中,方法头不正确的是(D)。A) public int x( ) . B) public static int x( doubl

13、e y ) . C) void x( double d ) D) public static x( double a ) . 13.为了区分重载多态中同名的不同方法,要求(A)。A) 采用不同的形式参数列表 B) 返回值类型不同 C) 参数名不同 D) 选项A、B、C都对14.在某个类中定义一个方法:void GetSort(int x),以下能作为这个方法的重载的是(ABCD)。Avoid GetSort(float x) x*=x; Bint GetSort(double y) return (int)(2*y);Cdouble GetSort(int x,int y) return x+

14、y;Dvoid GetSort(int x,int y) x=x+y;y=x-y15.若已定义:int a = 0,1,2,3,4,5,6,7,8,9 ;则对a数组元素正确的引用是(B)。 A) a-3 B) a9 C) a10 D) a(0)16.下面是在命令行运行Java应用程序A,怎样才能在main(String args)方法中访问单词first (BD)?java A the first snow , the first snow came.A)args0 B)args1 C)args2 D)args52判断一个数是否是回文数。根据/*/中的注释将下面的程序补充完整,使之编译通过并能

15、正确运行。import java.awt.*;import javax.swing.JOptionPane;public class Palindrome / main method begins execution of Java application public static void main( String args ) String resultString; / result String int number; / user input number int originalNumber; / stores original value in number for outpu

16、t int digit1; / first digit int digit2; / second digit int digit4; / fourth digit int digit5; / fifth digit int digits; / number of digits in input number = 0; digits = 0; /* Write code that inputs a five-digit number. Display an error message if the number is not five digits. Loop until a valid inp

17、ut is received. */ /* Write code that separates the digits in the five digit number. Use division to isolate the left-most digit in the number, use a remainder calculation to remove that digit from the number. Then repeat this process. Store the original value of number in variable originalNumber be

18、fore performing calculations. */ /* Write code that determines whether the first and last digits are identical and the second and fourth digits are identical. Assign resultString a string indicating whether or not the original string is a palindrome. */ /* Display whether or not the given number is

19、a palindrome. */ System.exit( 0 ); / end method main / end class Palindrome第3章 类、类的继承和接口一. 概念复习和巩固(请在课后和上机前完成下面的练习)3.下列选项中,用于在定义类头时声明父类名的关键字是(D)。A)package B)interface C)class D)extends4.定义类头时可以使用的访问控制符是(CD)。A) private B) protected C) public D) 缺省的,即没有访问控制修饰符5.有一个类A,对于其构造函数的声明正确的是( B )。A)void A(int x

20、). B)A(int x).C)A A(int x). D)int A(int x).7.设类B是类C的父类,下列声明对象x1的语句中不正确的是(D)。A)B x1= new B( ); B) B x1=new C( ); C)C x1=new C( ); D) C x1=new B( );8. 编译运行下面的程序,结果是(A)。public class A public static void main (String args) B b=new B( ); this.test(); public void test() System.out.print (A); class B exten

21、ds A void test() super.test(); System.out.println(B); A)产生编译错误,因为类B覆盖类A的方法test()时,降低了其访问控制的级别。 B)代码可以编译运行,并输出结果:AB。C)代码可以编译运行,但没有输出。D)代码可以编译运行,并输出结果:A。9.下面的程序编译运行的结果是(A)。public class A implements B public static void main (String args) int m,n; A t= new A(); m= t.k; n= B.k; System.out.println(m+,+n)

22、; interface B int k = 5;A)5,5 B)0,5 C) 0,0 D)编译程序产生编译错误10.为了使包abc中的所有类在当前程序中可见,可以使用的语句是(A)。A)import abc.*; B)package abc.*;C)import abc; D) package abc;2.下面的程序Complex.java定义一个复数类,ComplexTest.java测试该复数类。根据/*/中的注释将下面的程序补充完整,使之编译通过并能正确运行。=/ComplexTest.java/ Test the Complex number class=import javax.sw

23、ing.*;public class ComplexTest public static void main( String args ) Complex a, b; a = new Complex( 9.9, 7.7 ); b = new Complex( 1.4, 3.1 ); String result = a = + a.toComplexString(); result += nb = + b.toComplexString(); result += na + b = + a.add( b ).toComplexString(); result += na - b = + a.sub

24、tract( b ).toComplexString(); JOptionPane.showMessageDialog( null, result, Complex Test, JOptionPane.INFORMATION_MESSAGE ); System.exit( 0 ); =/Complex.java/ Definition of class Complex=public class Complex private double real; private double imaginary; / Initialize both parts to 0 /* Write header f

25、or a no-argument constructor. */ /* Write code here that calls the Complex constructor that takes 2 arguments and initializes both parts to 0 */ / Initialize real part to r and imaginary part to i /* Write header for constructor that takes two arguments梤eal part r and imaginary part i. */ /* Write l

26、ine of code that sets real part to r. */ /* Write line of code that sets imaginary part to i. */ / Add two Complex numbers public Complex add( Complex right ) /* Write code here that returns a Complex number in which the real part is the sum of the real part of this Complex object and the real part

27、of the Complex object passed to the method; and the imaginary part is the sum of the imaginary part of this Complex object and the imaginary part of the Complex object passed to the method. */ / Subtract two Complex numbers public Complex subtract( Complex right ) /* Write code here that returns a C

28、omplex number in which the real part is the difference between the real part of this Complex object and the real part of the Complex object passed to the method; and the imaginary part is the difference between the imaginary part of this Complex object and the imaginary part of the Complex object pa

29、ssed to the method. */ / Return String representation of a Complex number public String toComplexString() return ( + real + , + imaginary + ); / end class Complex第4章 Java系统类库和常用数据结构一. 概念复习和巩固(请在课后和上机前完成下面的练习)1.定义字符串s:String s=”Micrsoft公司”; 执行下面的语句,c的值为(B)。char c=s.charAt(9);A) 产生数组下标越界异常。B) 司 C) null D)

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1