CSCI A201 JAVA Midterm Exam
fully solved 2025(graded A+)
Given
String name;
the value of name is directly stored in its memory space. - answer
False
String objects are immutable. - answer True
Contents of the java.util package do not need to be imported into a
program in order to be used. - answer False
In order to use a predefined method, you simply need to know the
name of the method. - answer False
The method length in the class String returns the number of
characters in the string including whitespace characters. - answer
True
The method printf is used only to format the output of decimal
numbers. - answer False
The default output of decimal numbers of the type float is up to 15
decimal places. - answer False
A string consisting of only an integer or a floating-point number is
called a numeric string. - answer True
, The method parseInt is used to convert a numeric integer string into
a value of the type double. - answer False
The classes Integer, Float, and Double are not wrapper classes. -
answer False
Which of the following is a valid statement? - answer String name =
"Doe";
In Java, all variables declared using a class are ____. - answer
reference variables
Suppose str is a String variable. The statement
str = new String("Hello World");
is similar to which of the following? - answer str = "Hello World";
Which statement instructs a program to run the garbage collector? -
answer System.gc();
Suppose that str is a String variable. Write a Java statement that
uses the operator new to instantiate the object str and assign the
string "Java Programming" to str. - answer str = new String ("Java
Programming");
There are ____ types of methods in a class. - answer 2
Which package is automatically imported by the Java system? -
answer java.lang
What is the value of the following statement?
fully solved 2025(graded A+)
Given
String name;
the value of name is directly stored in its memory space. - answer
False
String objects are immutable. - answer True
Contents of the java.util package do not need to be imported into a
program in order to be used. - answer False
In order to use a predefined method, you simply need to know the
name of the method. - answer False
The method length in the class String returns the number of
characters in the string including whitespace characters. - answer
True
The method printf is used only to format the output of decimal
numbers. - answer False
The default output of decimal numbers of the type float is up to 15
decimal places. - answer False
A string consisting of only an integer or a floating-point number is
called a numeric string. - answer True
, The method parseInt is used to convert a numeric integer string into
a value of the type double. - answer False
The classes Integer, Float, and Double are not wrapper classes. -
answer False
Which of the following is a valid statement? - answer String name =
"Doe";
In Java, all variables declared using a class are ____. - answer
reference variables
Suppose str is a String variable. The statement
str = new String("Hello World");
is similar to which of the following? - answer str = "Hello World";
Which statement instructs a program to run the garbage collector? -
answer System.gc();
Suppose that str is a String variable. Write a Java statement that
uses the operator new to instantiate the object str and assign the
string "Java Programming" to str. - answer str = new String ("Java
Programming");
There are ____ types of methods in a class. - answer 2
Which package is automatically imported by the Java system? -
answer java.lang
What is the value of the following statement?