【Java】期末复习——基础知识题

一、判断题

1.可以使用throws语句来指明方法有异常抛出。(T)
2.类可以有两种重要的成员:成员变量和方法,类还可以有一种成员:内部类。(T)
3.对于abstract类,不能创建该类的对象。(T)
4.Every element in an array has the same type.(T)
5.Java中数组的元素只能是简单数据类型。(F)
6.java语言中不用区分字母的大写小写。(F)
7.Java语言中,变量名可以用汉字表示。(T)
8.Java的字符类型采用的是Unicode编码,每个Unicode码占16个比特。(T)
9.Java的各种数据类型占用固定长度,与具体的软硬件平台环境无关。(T)
10.boolean型数据的值只有true和false。(T)
11.构造函数名应与类名相同,返回类型为void。(F)
12.在Java程序中,可以使用private来修饰一个类。(T)
13.System类不能实例化,即不能创建System类的对象。(T)
14.引用一个类的属性或调用其方法,必须以这个类的对象为前缀。(F)
15.类也是一种数据类型,对象是类的实例(instance)。(T)
16.有的类定义时可以不定义构造函数,所以构造函数不是必需的。(F)
17.一个类的非静态方法可以访问静态成员变量,一个类的静态方法不可以访问该类的非静态成员变量。(T)
18.实例变量只能通过对象名访问,类变量既可以通过某个对象名也可以通过类名来访问。(T)
19.静态变量是被同一个类的所有实例所共享的。(T)
20.在实例方法或构造器中,this用来引用当前对象,通过使用this可引用当前对象的任何成员。(T)
21.String字符串在创建后可以被修改。(F)
22.StringBuffer类是线程安全的,StringBuilder类是线程不安全的。(T)
23.为了克服单继承的缺点,Java使用了接口,一个类可以实现多个接口。(T)
24.用户可以自定义自己的异常类。(T)
25.package语句必须放在java程序的最开始。(T)
26.对于abstract类,不能创建该类的对象。(T)
27.把数组中元素按照某种顺序排列的过程叫做查找。(F)
28.接口中的方法默认是public abstract方法。(T)
29.可以使用protected修饰符来防止方法和数据被不同包的非子类访问。(T)
30.一个数组可以存放许多不同类型的数值。(F)
31.final类中的属性和方法都必须被final修饰符修饰。(F)
32.所有异常都必须捕获。(F)
33.如果在子类的构造方法中,没有使用关键字super调用父类的某个构造方法,那么默认有super();语句,即调用父类的不带参数的构造方法。(T)
34.声明构造方法时,可以使用private访问修饰符。(F)
35.构造方法可以调用本类中重载的构造方法和它的父类的构造方法。(T)
36.设String对象s="Hello “,运行语句System.out.println(s.concat(“World!”));后String对象s的内容为"Hello world!”,所以语句输出为Hello world!。(F)
String永远不会发生改变,任何对String的操作都是另外返回一个新的String,而不是在原有的String上进行修改。(参考判断21)
37.类及其属性、方法可以同时有一个以上的修饰符来修饰。(T)
38.如果一个类的声明中没有使用extends关键字,这个类被系统默认为是继承Object类。(T)
39.Java中类和方法都不允许嵌套定义。(F)
40.当调用一个正在进行线程的stop()方法时,该线程便会进入休眠状态。(F)
41.如果一个类声明实现一个接口,但没有实现接口中的所有方法,那么这个类必须是abstract类。(T)
42.数组中有length()这个方法,如array.length()表示数组array中元素的个数。(F)
43.如果线程死亡,它便不能运行。(T)
44. The elements in an array must be a primitive data type.。(F)
45.如果使用import语句引入了整个包中的类,那么可能会增加编译时间。但绝对不会影响程序运行的性能,因为当程序执行时,只是将真正使用的类的字节码文件加载到内存。(T)
46. 在实例方法或构造器中,this用来引用当前对象,通过使用this可引用当前对象的任何成员。(T)
47. 一个try语句可以有多个catch语句与之对应。(T)

二、选择题

1.To add two nodes node1 and node2 into a pane, use __.
A.pane.addAll(node1, node2);
B.pane.getChildren().addAll(node1, node2);
C.pane.getChildren().add(node1, node2);
D.pane.add(node1, node2);

2.A派生出子类B,B派生出子类C,对于如下Java源代码正确的说法是()。

  1. A a0 =new A();
  2. A a1 =new B();
  3. A a2 =new C();

A.第1、2、3行能通过编译,但第2、3行运行时出错
B.只有第1行能通过编译
C.第1行、第2行和第3行的声明都是正确的
D.第1、2行能通过编译,但第3行编译出错

3.以下代码的输出结果为( )。

public class Pass{
     static int j = 20;
     public void amethod(int x){
         x = x*2;
         j = j*2;
    }
    public static void main(String args[]){
        int i = 10;
        Pass p = new Pass();
        p.amethod(i);
        System.out.println(i+" and "+j);
  }
}

A.10和40
B.20和40
C.错误:方法参数和变量不匹配
D.10和20

4.FilterOutputStream is the parent class for BufferedOutputStream, DataOutputStream and PrintStream. Which classes are valid argument for the constructor of a FilterOutputStream? ( )
A.StreamTokenizer
B.InputStream
C.OutputStream
D.RandomAccessFile

5.下面哪个Set是按照插入顺序排序的?
A.AbstractSet
B.LinkedHashSet
C.TreeSet
D.HashSet

6.关于垃圾收集的哪些叙述是对的。
A.程序开发者必须自己创建一个线程进行内存释放的工作。
B.垃圾收集将检查并释放不再使用的内存。
C.垃圾收集允许程序开发者明确指定并立即释放该内存。
D.垃圾收集能够在期望的时间释放被java对象使用的内存。

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

8.欲构造ArrayList类的一个实例,此类继承了List接口,下列哪个方法是正确的?( )
A.List myList=new List();
B.ArrayList myList=new Object();
C.ArrayList myList=new List();
D.List myList=new ArrayList();

9.The setOnAction method is defined in _________.
A.Node
B.Labelled
C.Button
D.Label
E.ButtonBase

10._______________ returns the selected item on a ComboBox cbo.
A.cbo.getSelectedIndex()
B.cbo.getSelectedItem()
C.cbo.getSelectedItems()
D.cbo.getSelectedIndices()
E.cbo.getValue()

11.关于类中成员变量的作用范围,下述说法中正确的是( )。
A.用static修饰的成员变量只能在用static修饰的方法中使用
B.类中所有成员变量在所有成员方法中有效
C.用private修饰的成员变量可以在main方法中直接使用
D.只有用public修饰的变量才能在所有方法中使用

12.How many items can be added into a ComboBox object?
A.Unlimited
B.2
C.1
D.0

13._______________ returns the selected item on a ComboBox cbo.
A.cbo.getSelectedIndex()
B.cbo.getSelectedItem()
C.cbo.getSelectedItems()
D.cbo.getSelectedIndices()
E.cbo.getValue()

14.To handle the key pressed event on a pane p, register the handler with p using __.
A.p.setOnKeyClicked(handler);
B.p.setOnKeyReleased(handler);
C.p.setOnKeyPressed(handler);
D.p.setOnKeyTyped(handler);

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

16.下面哪个对类的声明是错误的?
A.private class MyClass {}
B.abstract class MyClass implements YourInterface1, Youriterface2 {}
C.class MyClass extends MySuperClass1, MySupperClass2 {}
D.public class MyClass{}
E.class MyClass extends MySuperClass implements YourInterface {}

17.Which number for the argument must you use for the code to print cat? ( ) With the command: java Prog cat dog mouse public class Prog { public static void main(String args[]) { System.out.println(args[_______]) ; } }
A.1
B.0
C.3
D.2

18.Which of the following statements correctly rotates the button 45 degrees counterclockwise?
A.button.setRotate(Math.toRadians(45));
B.button.setRotate(360 - 45);
C.button.setRotate(45);
D.button.setRotate(-45);

19.你怎样强制对一个对象立即进行垃圾收集?
A.调用 Runtime.gc()
B.调用 System.gc()
C.调用System.gc(), 同时传递要进行垃圾收集对象的引用
D.垃圾收集是不能被强迫立即执行
E.给这个对象的所有引用设置一个新的值(例如null)

20.为AB类的一个无形式参数无返回值的方法method书写方法头,使得使用类名AB作为前缀就可以调用它,该方法头的形式为( )。
A.static void method( )
B.abstract void method( )
C.final void method( )
D.public void method( )

21.The method __ gets the contents of the text field tf.
A.tf.getText(s)
B.tf.getText()
C.tf.findString()
D.tf.getString()

22.To place a node in the left of a BorderPane p, use ___________.
A.p.setEast(node);
B.p.placeLeft(node);
C.p.left(node);
D.p.setLeft(node);

23.Which statement about the garbage collection mechanism are true? ( )
A.Garbage collection require additional programe code in cases where multiple threads are running.
B.The programmer has a mechanism that explicity and immediately frees the memory used by Java objects.
C.The garbage collection mechanism can free the memory used by Java Object at explection time.
D.The programmer can indicate that a reference through a local variable is no longer of interest.

24.To wrap a line in a text area jta on words, invoke ____.
A.jta.setWrapStyleWord(false)
B.jta.wrapStyleWord()
C.jta.setWrapStyleWord(true)
D.jta.wrapWord()

25.如果你被要求写一段代码读取一个文本文件,那么一般使用哪种Stream?
A.FileReader
B.ObjectInputStream
C.DataInputStream
D.FileInputStream

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

27.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()

28.To register a source for an action event with a handler, use __.
A.source.setActionHandler(handler)
B.source.addOnAction(handler)
C.source.addAction(handler)
D.source.setOnAction(handler)

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

30.类中某方法定义如下: double fun(int a,int b){ return a*1.0/b; } 同一类内其它方法调用该方法的正确方式是( )。
A.int x = fun(1.0,2.0)
B.double a = fun(1.0,2.0)
C.double a = fun(1,2)
D.int x = fun(1,2)

31._______ checks whether the RadioButton rb is selected.
A.rb.getSelected()
B.rb.isSelected().
C.rb.selected()
D.rb.select()

32.Fill in the code in the underlined location to display the mouse point location when the mouse is pressed in the pane.

import javafx.application.Application;
######import javafx.scene.Scene; ######import javafx.scene.layout.Pane; ######import javafx.stage.Stage;
######public class Test extends Application { ######@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
######Pane pane = new Pane();
( ____ )
######Scene scene = new Scene(pane, 200, 250); ######primaryStage.setTitle("Test"); // Set the stage title ######primaryStage.setScene(scene); // Place the scene in the stage ######primaryStage.show(); // Display the stage ######}
######/**
* The main method is only needed for the IDE with limited JavaFX
######* support. Not needed for running from the command line. ######*/ ######public static void main(String[] args) {
launch(args);
######} ######}

A.pane.setOnMouseClicked((e) -> System.out.println(e.getX() + ", " + e.getY()));
B.pane.setOnMouseDragged((e) -> System.out.println(e.getX() + ", " + e.getY()));
C.pane.setOnMousePressed(e -> System.out.println(e.getX() + ", " + e.getY()));
D.pane.setOnMouseReleased(e -> {System.out.println(e.getX() + ", " + e.getY())});

33.下面说法不正确的是( )
A.父类比它的子类的方法更多;
B.当子类对象和父类对象能接收同样的消息时,它们针对消息产生的行为可能不同;
C.子类在构造函数中可以使用super( )来调用父类的构造函数;
D.一个子类的对象可以接收父类对象能接收的消息;

34.Which correctly create an array of five empty Strings? ( )
A.String a [5];
B.String [] a = new String[5]; for (int i = 0; i < 5; a[i++] = null);
C.String [5] a;
D.String a [] = {"", “”, “”, “”, “”, “”};

35.下面哪个Map是排序的?
A.WeakHashMap
B.LinkedHashMap
C.TreeMap
D.HashMap
E.Hashtable

36.To register a source for an action event with a handler, use __.
A.source.addAction(handler)
B.source.setActionHandler(handler)
C.source.setOnAction(handler)
D.source.addOnAction(handler)

37.下列数组声明,下列表示错误的是( )
A.int[ ] a
B.int[ ]a[ ]
C.int[ ][ ] a
D.int a[ ]

38.The statement for registering a listener for processing list view item change is ___________.
A.lv.getSelectionModel().addListener(e -> {processStatements});
B.lv.addListener(e -> {processStatements});
C.lv.getItems().addListener(e -> {processStatements});
D.lv.getSelectionModel().selectedItemProperty().addListener(e -> {processStatements});

39.To wrap a line in a text area ta, invoke ____.
A.ta.WrapLine()
B.ta.wrapText()
C.ta.setLineWrap(true)
D.ta.setWrapText(true)
E.ta.setLineWrap(false)

40.要创建一个新目录,可以用下面( )类实现。
A.File
B.RandomAccessFile
C.FileOutputStream
D.FileInputStream
41. 下列选项中,用于实现接口的关键字是 ( )。
A.abstract
B.implements
C.class
D.interface
42. 执行完以下代码int [ ] x = new int[10];后,以下哪项说明是正确的( )
A.x[9]未定义
B.x[10]为0
C.x[0]为空
D.x[9]为0
43. To place two nodes node1 and node2 in a HBox p, use _________.
A.p.addAll(node1,node2);
B.p.getChildren().addAll(node1,node2);
C.p.getChildren().add(node1, node2);
D.p.add(node1, node2);
44. Fill in the code below in the underline:public class Test {######public static void main(String[] args) {Test test = new Test();######test.setAction(
);}######public void setAction(T1 t) { ######t.m();}######} ######interface T1 { ######public void m(); ######}
A.System.out.print("Action 1! ")
B.(e) -> System.out.print("Action 1! ")
C.(e) -> {System.out.print("Action 1! ")}
D.() -> System.out.print("Action 1! ")
45. To remove two nodes node1 and node2 from a pane, use __.
A.pane.removeAll(node1,node2);
B.pane.getChildren().removeAll(node1,node2);
C.pane.remove(node1,node2);
D.pane.getChildren().remove(node1, node2);

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值