今天看啥  ›  专栏  ›  poipoi626

java语言程序设计练习(选择题)

poipoi626  · CSDN  ·  · 2020-01-05 10:15

java语言程序设计练习(选择题)

期末考试( 整活 )复习
从平时的练习题里选摘出来的一点点

选择题部分

1.在Java中,负责对字节代码解释执行的是 ( B )
A.应用服务器
B.虚拟机
C.垃圾回收器
D.编译


2.Java程序默认引用的包是( C )
A.java.text包
B.java.awt包
C.java.lang包
D.java.util包


3.下列关于System类的叙述中,错误的是( C )
A.System类是一个final类
B.System类不能实例化
C.System类中没有定义属性
D.System类主要提供了系统环境参数的访问


4.在面向对象的软件系统中,不同类对象之间的通信的一种构造称为_D_。
A.属性
B.封装
C.类
D.消息


5.在面向对象方法中,继承定义了超类和子类的概念,子类在维持原有父类中方法签名不变的前提下,用适合于自己要求的实现去置换父类中的相应方法的实现称为_B_。
A.继承
B.覆盖(overriding)
C.重载(overloading)
D.多态


6.以下哪句是错误的?_ C _
A.编译器会搜索要import的类的编译结果文件而不是源文件
B.import是告诉编译器要import的包的信息
C.import是把要import的类的源代码插入到import语句所在的地方
D.编译器在编译的时候需要能访问得到要import的类的编译结果文件


7.下面哪一个描述是正确的? _ B _
A.Node对象可以被放置在 Scene中.
B.Node对象可以被放置在 Pane中.
C.Shape 对象可以被放置在Control中.
D.Pane对象可以被放置在Control中.


8.为了从pane中删除两个节点 node1和node2 ,使用下面哪一个语句 _ A _.
A.pane.removeAll(node1, node2);
B.pane.remove(node1, node2);
C.pane.getChildren().removeAll(node1, node2);
D.pane.getChildren().remove(node1, node2);


9.为了在BorderPane p的左部放置一个node对象, 使用下面哪一个语句 _ A _.
A.p.setLeft(node);
B.p.placeLeft(node);
C.p.left(node);
D.p.setEast(node);


10.声明并创建一个按钮对象b,应该使用的语句是( A )
A.Button b=new Button( );
B.button b=new button( );
C.Button b=new b( );
D.b.setLabel(“确定”);


11.如果需要从文件中读取数据,则可以在程序中创建哪一个类的对象( A )。
A.FileInputStream
B.FileOutputStream
C.DataOutputStream
D.FileWriter


12.关于以下程序代码的说明正确的是( D ) 。

class  HasStatic{
    private  static  int  x=100public  static  void  main(String[  ]  args){ 
        HasStatic  hs1=new  HasStatic(  ); 
        hs1.x++;
        HasStatic  hs2=new  HasStatic(  ); 
        hs2.x++;
        hs1=new  HasStatic( ); 
        hs1.x++;
       HasStatic.x--;
       System.out.println(“x=+x); 
    } 
 }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

A.5行不能通过编译,因为引用了私有静态变量
B.10行不能通过编译,因为x是私有静态变量
C.程序通过编译,输出结果为:x=103
D.程序通过编译,输出结果为:x=102


13.下面哪一句是关于非静态的内部类正确的描述?
A.It must implement an interface.
B.It can access private instance variables in the enclosing object.
C.It is accessible from any other class.
D.It can only be instantiated in the enclosing class.
E.It must be final if it is declared in a method scope.


14.以下关于Java的局部内部类的说法错误的是( A )
A.局部内部类只能在当前类中使用
B.局部内部类不能包含静态成员
C.局部内部类可以访问外部类的所有成员
D.在局部内部类中定义的内部类不能被private修饰符修饰


15.以下程序段输出结果的是( C )

public class Test {
     public static void main(String args[]){
          String str="ABCDE";
          str.substring(3);
          str.concat("XYZ");
          System.out.print(str);
     }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

A.DE
B.DEXYZ
C.ABCDE
D.CDEXYZ


16.下面哪个函数是public void aMethod(){…}的重载函数?( D )
A.void aMethod( ){…}
B.public int aMethod(){…}
C.public void aMethod ( ){…}
D.public int aMethod ( int m){…}


17.Which keyword is used to make a class definition include the non-private attributes and behaviors of a parent class, as well as additional attributes and behaviors that are specific to the class being defined?
A.extends
B.super
C.inheritance
D.finalizer


18.A JavaFX action event handler contains a method _ D _.
A.public void actionPerformed(ActionEvent e)
B.public void handle(Event e)
C.public void actionPerformed(Event e)
D.public void handle(ActionEvent e)


19.A JavaFX action event handler is an instance of _ A _.
A.EventHandler< ActionEvent>
B.EventHandler
C.ActionEvent
D.Action


20.A JavaFX event handler for event type T is an instance of _ A _.
A.EventHandler < T >
B.ActionEvent
C.Action
D.EventHandler


21.To handle the mouse click event on a pane p, register the handler with p using _ A _.
A. p.setOnMouseClicked(handler);
B. p.setOnMouseReleased(handler);
C. p.setOnMouseDragged(handler);
D. p.setOnMousePressed(handler);


22.Suppose A is an anonymous inner class in Test. A is compiled into a file named _ D _.
A. A.class
B. Test$A.class

C. A$Test.class
D.Test$1.class
E.Test&1.class


23.To place two nodes node1 and node2 in a HBox p, use _.
A. p.addAll(node1, node2);
B. p.add(node1, node2);
C. p.getChildren().addAll(node1, node2);
D. p.getChildren().add(node1, node2);


24.Suppose a JavaFX class has a binding property named weight of the type DoubleProperty. By convention, which of the following methods are defined in the class?
A.public double getWeight()
B.public DoubleProperty weightProperty()
C.public DoubleProperty WeightProperty()
D.public void setWeight(double v)
E.public double weightProperty()


25.To add a node to the the first row and second column in a GridPane pane, use _ D _.
A. pane.getChildren().add(node, 1, 2);
B. pane.add(node, 1, 2);
C. pane.getChildren().add(node, 0, 1);
D. pane.add(node, 1, 0);
E. pane.add(node, 0, 1);


26.If this source code is contained in a file called SmallProg.java, what command should be used to compile it using the JDK? ( B )

public class SmallProg { 
public static void main(String args[]) { System.out.println("Good luck!"); }
}
  • 1
  • 2
  • 3

A.java SmallProg
B.javac SmallProg
C.java SmallProg.java
D.javac SmallProg.java


27.如果需要从文件中读取数据,则可以在程序中创建哪一个类的对象( A )。
A.FileInputStream
B.FileOutputStream
C.DataOutputStream
D.FileWriter


28.Which of the following computer components are referred to as hardware?
A.monitor, keyboard, and programs
B.mouse, CPU, and programs
C.monitor, CPU, and keyboard
D.keyboard, programs, and mouse


29.What kind of reader do you use to handle Character code? ( A )
A.Reader
B.Writer
C.PrintWriter
D.InputStreamReader


30.Object of which class below can be real parameter of constructor of DataInputStream?( C )
A.File
B.String
C.FilterInputStream
D.FileOutputStream


31.Below is the function header for write() in OutputStream

	void write(int b)
  • 1

. Now given code below, what would be the size and the content of the output file?

int i=0xcafebabe;
FileOutputStream out = new FileOutputStream("output");
out.write(i);
  • 1
  • 2
  • 3

A. 1 byte and 0xbe
B. 1 byte and 0xca
C. 4 bytes as 0xcafebabe
D. 4 bytes as 0xbebafeca


32.For InputStream.read(), the read() with no parameters, which statement below is correct?
A. read() returns int, because it has to return EOF to indicate the end of the file
B. read() returns byte, because it reads a byte from the stream
C. read() returns char, because it reads a char from the stream
D. read() returns int, as the number of bytes it just read


33.Given:

void write() throws IOException {
	DataOutputStream out = new DataOutputStream(
		new BufferedOutputStream(
			new FileOutputStream(
				new File("data.out"))));
	out.writeInt(123456);
	out.close();
} 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

After executing the function, the size of the file “data.out” is:
A. 4
B. 6
C. 7
D. Depends on the OS


34.以下哪个关键字可以用来给对象加互斥锁?( B )
A.transient
B.synchronized
C.serialize
D.static


35.Which method you define as the starting point of new thread in a class from which new the thread can be excution? ( B )
A.public void start()
B.public void run()
C.public void int()
D.public static void main(String args[])


36.下列哪个一个操作不能使线程从等待阻塞状态进入对象阻塞状态( A )。
A.等待阻塞状态下的线程被notify()唤醒
B.等待阻塞状态下的纯种被interrput()中断
C.等待时间到
D.等待阻塞状态下的线程调用wait()方法


37.下列说法中错误的一项是( C )。
A.一个线程是一个Thread类的实例。
B.线程从传递给纯种的Runnable实例run()方法开始执行。
C.新建的线程调用start()方法就能立即进入运行状态.
D.线程操作的数据来自Runnable实例


38.对于类与对象的关系,以下说法错误的是( D )。
A.类是对象的类型
B.对象由类来创建
C.类是同类对象的抽象
D.对象是创建类的模板


39.以下关于继承的叙述正确的是( A )。
A.在Java中类只允许单一继承
B.在Java中一个类只能实现一个接口
C.在Java中一个类不能同时继承一个类和实现一个接口
D.在Java中接口只允许单一继承


40.一个.java文件中可以包含多少个public类?
A.最多1个
B.最少1个
C.只能是0个
D.不限制


41.在Java中,一个类可同时定义许多同名的方法,这些方法的形式参数个数、类型或顺序各不相同,传回的值也可以不相同。这种面向对象程序的特性称为( C )。
A.隐藏
B.覆盖
C.重载
D.Java不支持此特性


42.下面是People和Child类的定义和构造方法,每个构造方法都输出编号。在执行new Child(“mike”)的时候都有哪些构造方法被顺序调用?请选择输出结果 ( D )

class People { 
        String name; 
        public People() {
               System.out.print(1); 
        }
        public People(String name) {
               System.out.print(2); 
               this.name = name;
        } 
} 
class Child extends People {
       People father; 
       public Child(String name) {
              System.out.print(3); 
              this.name = name; 
              father = new People(name + ":F");
       } 
       public Child(){ 
             System.out.print(4);
       } 
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

A.312
B.32
C.432
D.132


后面还会有函数题…

给的英文题就很离谱 ,能力有限那咋办嘛…




原文地址:访问原文地址
快照地址: 访问文章快照