多选题Given the SampleClass, what is the value of currentCount for the
instance of object x after the code segment had be executed?
SampleClass x = new SampleClass(); SampleClass y = new
SampleClass(); x.increaseCount(); public class
SampleClass { private static int currentCount=();
public SampleClass() { currentCount++;
} public void increaseCount() {
currentCount++; } }
A. 0
B. 1
C. 2
D. 3
E. Compiler error
F. Runtime error
多选题When the void keyword is used, which of the following statements are true? (Choose all that apply.)
A. A return statement with a value following it must be used.
B. A return statement with a value following it can optionally be used.
C. A return statement with a value following it should never be used.
D. A return statement by itself must be used.
E. A return statement by itself can optionally be used.
F. A return statement by itself should never be used.
G. A return statement must be omitted.
H. A return statement can optionally be omitted.
I. A return statement should never be omitted.
多选题Given: public class Dinner { public
static void main (String[] args) { boolean
isKeeperFish = false; if (isKeeperFish = true) {
System.out.println("Fish for dinner"); } else
{ System.out.println("Take out for dinner");
} } } What will be the result
of the application's execution?
A. Fish for dinner will be printed.
B. Take out for dinner will be printed.
C. A compilation error will occur.
多选题Which set of operators represents the complete set of valid Java
assignment operators?
A. %=, &=, *=, $=, :=, /=, ^=, |=, +=, <<=, =, -=, >>=, >>>=
B. %=, &=, *=, /=, ^=, |=, +=, <<=, <<<=, =, -=, >>=, >>>=
C. %=, &=, *=, /=, ^=, |, +=, <<=, =, -=, >>=, >>>=
D. %=, &=, *=, $=, /=, ^=, |=, +=, <<=, <<<=, =, -=, >>=, >>>=
多选题What is wrong with the following method? public
double interestDue(double currentBalance, float interestRate) {
double interestDue = currentBalance * interestRate; return
interestDue; }
A. It should use all float primitives.
B. It should use all Float objects.
C. It should use all double primitives.
D. It should use all Double objects.
E. It should use BigDecimal objects.
F. Nothing is wrong with this method.
G. It does not compile because you cannot do math operations with primitives
that are not the same type.
多选题For standard situations what is typically the best type of array to
use?
A. ArrayList
B. One-dimensional array
C. Multi-dimensional array
多选题What is the best data type to use when storing a status code that may
have one of the following values: success, failed, success with errors, or
undetermined?
A. Object
B. Class
C. boolean
D. enum
E. int
多选题You need to update a value of a hash table (that is, HashMap) where
the primary key must equal a specified string. Which statements would you need
to use in the implementation of this algorithm?
A. Iteration statement
B. Expression statement
C. Conditional statement
D. Transfer of control statement
多选题下面关于java中输入/输出流的说法正确的是______。 A.FileInputStream与FileOutputStream类用读、写字节流。 B.Reader与Writer类用来读、写字符流。 C.RandomAccessFile既可以用来读文件,也可以用来写文件。 D.File类用来处理与文件相关的操作。
填空题线程的优先级在______至______之间,数值越大______。
填空题创建一个名为 MyPackage 的包的语句是______,该语句应该放在程序的位置为:______。
填空题在一个时间只能由一个线程访问的资源称为______。访问临界资源的代码______。
填空题构造方法是一种特殊的成员方法,构造方法名与______相同。
填空题按要求填空 abstract class SuperAbstract void a()… abstract void b(); abstract int c(int i); interface AsSuper void x(); abstract class SubAbstract extends SuperAbstract implements AsSuper public void b()… abstract String f(); public class InheritAbstract extends SubAbstract public void x()… public int c(int i ) … public String f()… public static void main(String args[]) InheritAbstract instance=new InheritAbstract(); instance.x(); instance.a(); instance.b(); instance.c(100); System.out.println(instance.f()); 在以上这段程序中: 抽象类有:SuperAbstract和 (1) (写出类名) 非抽象类有: (2) (写出类名) 接口有: (3) (写出接口名) AsSuper中的x()方法是(4)方法,所以在InheritAbstract中必须对它进行(5)
填空题按注释完成程序 public class Leaf private int i = 0; //此属性值用于检验 Leaf increment() //定义方法increment(),返回值是Leaf类的对象 i++; return (1) ;//将当前对象的地址作为返回值返回 void print() System.out.println(" i = " + i); public static void main(String args[]) Leaf x = (2); //创建Leaf类的对象x x.increment().increment().increment().print(); //多次调用方法increment(),返回的都是x的地址,i 值表示调用次数 输出结果为 i = (3)
填空题Java语言只允许单继承,指每个类只能有一个______。
填空题如果一个Java Applet源程序文件只定义有一个类,该类的类名为MyApplet,则类MyApplet必须是______类的子类并且存储该源程序文件的文件名为______。
填空题Java中布尔类型的常量有两种,它们是______和______。
填空题按注释提示完成文件复制的程序 //FileStream源代码如下: import java.io.*; class FileStream public static void main(String args []) try File inFile = new File("file1.txt"); //指定源文件 File outFile = new File("file2.txt"); //指定目标文件 FileInputStream fis =(1); FileOutputStream fos = new FileOutputStream(outFile); int c; //逐字节从源文件中输入,再输出到fos流 while ((c = fis.read ())!=-1) (2); fis.close(); fos.close(); catch (Exception e) System.out.println("FileStreamsTest: "+e);
填空题以下程序的输出结果为______。 public class Course private String cNumber; private String cName; private int cUnit; public Course(String number, String name, int unit) cNumber = number; cName = name; cUnit = unit; public void printCourseInfo______ System.out.println("课程号:" + cNumber + " 课程名:" + cName + " 学分:" + cUnit); class CourseTest public static void main(String[] args) Course c; c = new Course("101", "ASP", 3); c.printCourseInfo______;
