CS 321 Exam 1, 2, and Quiz 1
In Java, String objects are mutable. (T/F)
False
Java allows multiple inheritance (T/F)
False
Java achieves platform independency mainly though the use of
JVM
Consider parameter passing in Java, which one of the following is true? Java can pass pointers and references Java uses call by value when passing parameters Java cannot pass a primitive value
Java uses call by value when passing parameters
Which of these are not primitive data types? int String Dog char float boolean
String Dog
In Java, any array has a built in variable which stores the length of the array. (T/F)
True
In java.lang.package, there is a Math class. We know that we can use MATH.PI in our programs. This indicates that PI must be a public static class variable of the Math Class. (T/F)
True
java.lang.Object is the root class for Java class hierarchy (t/f)
True
In Java, for WindowEvent, there is a WindowListener interface which has seven methods. If you only want to use one, what design pattern could you use to accomplish this?
adapter
Consider the HotTemperatureException class discussed in class for modeling cars, this exception should be what kind?
checked exception
What are the five C's used to evaluate the implementation of a class?
convenience cohesion completeness clarity consistency
What are the 8 types of primitive data types?
double int float char bool byte long short
java.lang and java.lang.reflect refer to the same package (T/F)
false
The keyword allowing a Java class file to use a premade java package is
import
You want to use another Java package, the keyword to use is:
import
For Java's GUI and event-driven programming, there are three packages which we often need to use/import. What are they?
java.awt* java.Swing* java.awt.event*
Which class in java.io package adapts an InputStream object into a Reader object?
java.io.inputStreamReader
When implementing a JComponent class, there is a method which one needs to pay special attention, for if the method is not overridden, then when the component is resized, the drawing in the component would not be repainted. What is it?
paintComponent()
You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective? public private protected transient
protected
Consider the class, public class Test{} Which constructor is usable by other groups? private Test() Test(void) public Test() public TestConstructor()
public Test()
Which of the following is a valid declaration within an interface definition? public double methoda() public final double methoda() static void methoda(double d1)
public double methoda()
The entry point of a Java program is what function?
public static void main(String args[])
Which is a valid keyword in Java? throw virtual generics unsigned
throw
A final method cannot be overridden by methods in the subclass. (T/F)
true
All the java source files in one particular package have to be placed in the same directory. (T/F)
true
An exception in Java is treated as an object as well. (T/F)
true
Every Java class file is included in a package. (T/F)
true
Every java class/interface is included in a java package. (T/F)
true
The command line arguments in Java are treated as a string array. (T/F)
true
When implementing a class, it is possible for one to use different representations (using different raw materials to build this new kind of objects). (T/F)
true
When writing a java class, what should you do if you want the objects instantiated from the class can be saved directly into files?
use serialization