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

《Java程序设计》试卷(A卷)

来源:用户分享 时间:2025/7/24 8:08:17 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

《Java程序设计》试卷(A卷)

课程代码:131300210

本试卷用于10级计算机科学与技术专业、网络工程专业

(时量:120分钟 总分100分)

注意: 1、答案必须填写在答题纸上,填写在试卷上的无效。

2、答案必须写明题目序号,并按题号顺序答题。

3、请保持行距,保持卷面整洁。 一、which of the following is a correct answer(2*10)

1. ( ) are essential to prepare to the environment for java programming in the computer.. A. JDK B. Java Doc120umentation C. IDE D. all of above 2. the beginning and ending of a method is denoted by ( ). A. { } B. ( ) C. [ ] D. < > 3. javac acts on a file of ( ) extension

A. “.class” B. “.java” C. “.exe” D. “.jar”

4.( ) provides the classes for implementing networking applications

A. java.applet B. java. Lang C. java.net D. java.util in java ,we can define 5. ( ) is the valid identifier

A. main B. $HELLO C. hello&world D. 3hello

6. Access modifier ( ) is accessible from within any class in the same package, and also from within may class hat inherits directly or indirectly from the class. A. public B. protected C. default D. private 7. which is true about abstract class

A. abstract class can not create instances using the new operator. B. abstract class has only abstract method. C. abstract class has not subclass.

D. all subclasses of an abstract class must implement any abstract methods defined in the superclass.

8. which is not method of class scanner

A. nextInt( ) B. nextFloat( ) C. nextBoolean() D. nextSring( ) 9. What will happen when you compile and run the following code? public class MyClass{ static int i;

public static void main(String argv[]){ System.out.println(i); } }

A. Error Variable i may not have been initialized B. null C. 1 D. 0 10. which is true ( )

A. inner class is a class defined within the scope of another class and is nested within a class. B. an inner class is compiled into a class named innnerclassname.class C. inner class can?t be declared static.

D. objects of an inner class cant be created from another class.

二、write the correct in the blanks (3*5)

共4页,第1页

_____________________ Class NumericInput{

Public static void main (String args[]) ____________{

BuffereredReader br =new BufferedReader(new InputStreamReader(__________)); int age;

System.out.print(“please enter your age:”); Age=-___________(_____________); System.out.println(“you age is:”+age); } }

三、What is the output from the following program (5*5)

1.

public class Charlie extends Bravo{

public static void main() {new Charlie()} public Charlie(){

System.out.println(“in Charlie?s no-arg constructor”); } }

Class Bravo extends Alpha{ public Bravo(){

this(?IN Braveo\\s overloaded constructor”);

System.out.printtln(“in Bravo?s no- arg contstructor”);

}

Public Bravo(String s) { System.out.println(s); } }

Class Alph{

public Alpha(){

System.out.println(“in alpha?s no- arg constructor”); } }

2. class Mystery{

public static void main(String[] args){ int tempResult=2; int w=3, x=9,y=2,z=6; if ( (w!=x)&&(y==(z/e) ) ){ System.out.prinltn(“output A”); }

else{

System.out.println(“output B”); }

tempResult *=x++*--y;

System.out.println(“tempRseult=”+tempResult);

共4页,第2页

System.out.println(“x=”+x); System.out.println(“y=”+y); }

3. public class Outer{

public static void main(String args[]){ for(int i=0; i〈3; i++)

for(int j=0;j〈3;j++){ if(j= =1) break;

System.out.println(j+\ } } }

4. class output{

static double a=1.5;

Static void setA(double number) {int a=(int) number;} public static void main(String[] args{ seta(a);

System.out.println(a); } }

5. public class X{

public static void main(String[] args){ int[] a=new int[1]; modify(a);

System.out.println(a[0]); }

public static void modify(int[] a){ a[0]++;} }

五、What is wrong in the following code (2*10)

1. final class First {

private int a = 1; int b = 2; } class Second extends First { public method() {

System.out.println(a + b); } } 2. public class circle {

private double radius;

public void Circle(double radius){ radius=radius; }

public double findArea() { return radius*radius* PI;

共4页,第3页

} }

class Cylinder implement Circle{ private double length;

Cylinder(double radius, double length){ Circle(radius); Length=length;}

/**return the surface area for the cylinder*/ public double findArea(){ return findArea()*length; } }

六、Programming

1.Write a java program to do the following task: (12)

(a) write a static method that takes in array of int type and returns the greatest number in the array.

(b)declare an arry of int type initialized with 10 numbers in main() method.

(c) declare a statement in main( ) method that calls the method we defined in step (a) with the array as the input argument to the method

(d) display all the numbers in the array and also the greatest number in the array in main( ) as follows:

The numbers are 34 12 89 988 54 90 123 666 58 2 The greatest number is 988

2. write a java program to do following task (8)

(a) define a interface with two method: calculateArea( ) (计算面积)

and calculatePerimeter();(计算周长)

(b) define a class circle to implement the interface.

共4页,第4页

搜索更多关于: 《Java程序设计》试卷(A卷) 的文档
《Java程序设计》试卷(A卷).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c8w2871nnlq0cqsj0v4uc_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top