QUESTION 1 This and the next two questions are based on the following program: I
ID: 3594324 • Letter: Q
Question
QUESTION 1
This and the next two questions are based on the following program:
In the main method after the program has evaluated all statements before the comment, what is the value of x.length? _________
QUESTION 2
What is the value of r1?
null
0
2
3
QUESTION 3
What is the value of r2? _____
QUESTION 4
A UML class diagram has the following description about a member of the class:
+ getHeaderField(name:String):String
Which of the following is a correct declaration of the member in Java?
public String getHeaderField;
public String getHeaderField(String)
getHeaderField
public static String getHeaderField( name)
QUESTION 5
Note: all answers are case sensitive.
Inside a class, the declaration of a constructor looks like the following:
public JButton(String text)
1. From the constructor, you infer that the name of the class containing the constructor must be _______ .
2. Fill in the blanks so that the statement will instantiate a JButton object and assigns it to variable of JButton type:
JButton btn= _______ ("OK");
3. Fill in the blanks to complete the description of the constructor in the corresponding UML class diagram:
+<<constructor>>______( _____ : ______)
QUESTION 6
Are the methods in the following code correctly overloaded?
a. True
b. False
QUESTION 7
Assume the following class has been implemented:
In another class, you want to use the log method in Tool class. Which statement uses the method correctly?
double x
double x = log(2,8);
double x = Tool.log(2,8);
double X
QUESTION 8
Fill in the blanks to complete the following program.
QUESTION 9
Does the following code involve illegal duplication variable declarations?
a. True
b. False
a.null
b.0
c.2
d.3
Explanation / Answer
Question 1: 3
Question 2: 0
Question 3: 3
Question 4: b. public String getHeaderField(String)
Question 5:
1. JButton
2. JButton btn = new JButton("OK");
3. JButton(text: name)
Question 6:
a. True
Question 7: c. double x = Tool.log(2,8);
Question 8:
public class Car{
private String model;
private int year;
public Car(String model, int year) { //2-argument constructor
this.model = model;
this.year = year;
}
public Car(String model) {
Car(model, 2017); //call the 2-argument constructor
}
//getters and setters omitted for brevity.
}
Question 9:
b. False
**Comment for any further queries. Upvote if the answer is satisfactory.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.