QUESTION 1 A static variable of a class cannot be changed. True False 2 points Q
ID: 3797482 • Letter: Q
Question
QUESTION 1
A static variable of a class cannot be changed.
True
False
2 points
QUESTION 2
A .java file may have any number of public classes.
True
False
2 points
QUESTION 3
The following statement correctly creates a Scanner object for user input from the keyboard.
Scanner kb = new Scanner(System.keyboard);
True
False
2 points
QUESTION 4
A class is an instance of an object.
True
False
2 points
QUESTION 5
A class can have any number of constructors.
True
False
2 points
QUESTION 6
The functions or data members declared private in a class can only be accessed only through definition those functions declared in that class.
True
False
2 points
QUESTION 7
You can write a class that is useful with all its methods and variables declared private.
True
False
2 points
QUESTION 8
A class member that is to be shared among all objects of a class is called
A final member
A reference member
A static member
A value member
3 points
QUESTION 9
What will be the output of the following code fragment?
{
System.out.println("result = " + 1 + 4);
}
result = 5
result = 14
result = 0
result = null
3 points
QUESTION 10
When saving a Java source file, save it with the extension of
.java
.javac
.class
.src
3 points
QUESTION 11
A file with the .class extension means that the file:
Contains Java source code.
Contains HTML.
was produced by the Java compiler.
was produced by the Java interpreter.
3 points
QUESTION 12
Which of the following are correct?
A constructor must be declared with a return type
A constructor must be declared for each class.
A class can have only one default constructor.
A default constructor can only be provided by the java compiler.
3 points
QUESTION 13
Which keyword do we use to specify a constant variable ? (one the does not change after the initial assignment)
const
constant
final
fixed
3 points
QUESTION 14
Which Java package includes the Scanner class?
awt
swing
util
lang
3 points
QUESTION 15
Which of the following statements is used to terminate the current interation of the loop, and go on the next interation of the loop?
break;
continue;
switch
if .... else .... ;
3 points
QUESTION 16
What does the following Boolean expression evaluate to?
(!(5 < 3))
unknown
true
false
null
A final member
A reference member
A static member
A value member
Explanation / Answer
Answer 1:
false. Static variable can be changed. Static means the variable is tied directly to the class, not an object.
Answer 2 :
true. It can have multiple public classes. But when you run the file, the name of the file must match one class.
Answer 3 :
false. It should be system.in, not system.keyboard
Answer:
4 is false. An object is an instance of a class. Not class is an instance of an object.
Answer :
5 is true. A class can have many constructors, as long as there is no conflict.
Answer :
6 is true.
Answer:
7 is true I think. You can keep everything private, if you have a main function and you are only running the same class file.
8)
A static Member , 8, there is no such thing as reference or value member. Final member means the variable cannot be changed. But not necessarily mean it is shared. Static means it is shared, because it is tied to the class, not the object.
9) the compiler reads from left to right. So the left element is string, "result =". So it will treat everything else as string, including 1 and 4, and will perform string concatenation making it 14. If you put a bracket around 1+4, then only it will print 5.
For 10 and 11, the interpreter, which is us, writes the java code first and save it in a .class file. Then in command prompt, we use the command javac. Once we use that command, the compiler reads the .class file and translate into .java file which the computer understands. Then you use the "java" command to make the computer run the file.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.