QUESTION 1
In Java, all variables declared using a class are ____.
a. |
reference variables |
|
b. |
constants |
|
c. |
primitive variables |
|
d. |
operators |
1 points
QUESTION 2
An expression such as str.length(); is an example of a(n) ____.
a. |
system call |
|
b. |
method call |
|
c. |
object call |
|
d. |
class |
1 points
QUESTION 3
Consider the following statements.
double x;
String y;
y = String.format( "%.2f", x);
If x = 285.679, what is the value of y?
a. |
"285.00" |
|
b. |
"285.680" |
|
c. |
"285.68" |
|
d. |
"285.068" |
1 points
QUESTION 4
A(n) ____ is a method of a class that is automatically executed when an object of the class is created.
a. |
constructor |
|
b. |
interface |
|
c. |
inheritance |
|
d. |
package |
1 points
QUESTION 5
Which of the following is a reserved word in Java?
a. |
inheritance |
|
b. |
extends |
|
c. |
event |
|
d. |
pane |
1 points
QUESTION 6
If Shape is a class and you create a new class Rectangle that
extends Shape, then Shape is a(n) ____ and Rectangle is a(n)
____.
Which word goes in the first blank in the sentence above?
a. |
superclass |
|
b. |
inherited class |
|
c. |
subclass |
|
d. |
package |
1 points
QUESTION 7
Which modifier is used to build classes on top of classes that are interfaces?
a. |
public |
|
b. |
implements |
|
c. |
new |
|
d. |
private |
1 points
QUESTION 8
Write a program that takes as input the pay rate and hours
worked of an employee and calculates the pay of the employee.
Based on the problem statement above, which of the following would
most likely be chosen as the class?
a. |
Pay |
|
b. |
Hours_Worked |
|
c. |
Pay_Rate |
|
d. |
Employee |
1 points
QUESTION 9
Write a program that takes as input the pay rate and hours
worked of an employee and calculates the pay of the employee.
Based on the problem statement above, which of the following would
be a data member?
a. |
job |
|
b. |
hoursWorked |
|
c. |
pay |
|
d. |
employee |
Please Note:
I have answered the first 4 questions as per the Chegg Answering
Guidelines. Please Re-post for the other Questions.
Answer)
QUESTION 1
a. reference variables - are the variables which are declared in
the class.
QUESTION 2
b. method call - length() is the method which is called here, thus
it is known as a method call
QUESTION 3
c. "285.68" - is the output of the above code. The value is
approximated to 285.68 till 2 characters to the right
QUESTION 4
a. constructor - is such a method which is called as soon as the
class object is loaded.
QUESTION 1 In Java, all variables declared using a class are ____. a. reference variables b....
Question 1 1 pts Which of the following is not a valid class name in Java? O MyClass MyClass1 My_Class MyClass# Question 2 1 pts Which of the following statements is False about instance variables and methods? Instance variables are usually defined with private access modifier. Instance variables are defined inside instance methods. Instance methods are invoked on an object of the class that contains the methods. A class can have more than one instance variables and methods. Question 3...
Java code for the following inheritance hierarchy figure.. 1. Create class Point, with two private instance variables x and y that represented for the coordinates for a point. Provide constructor for initialising two instance variables. Provide set and get methods for each instance variable, Provide toString method to return formatted string for a point coordinates. 2. Create class Circle, its inheritance from Point. Provide a integer private radius instance variable. Provide constructor to initialise the center coordinates and radius for...
Using the IST Linux system create the following Java command line inheritance application Lab4. Create the following project Java files: Point.java, Shape.java, Circle.java, Triangle.java, Rectangle.java, and Lab4.java Point.java will contain two coordinates x and y. This will be reused to create point objects to draw all the shapes. Shape.java will be the parent class and will contain a Point type. Circle.java, Triangle.java, Rectangle.java will all be children of Shapes.java class Each class (Circle, Triangle, Rectangle) will contain the private class...
My Java code from last assignment: Previous Java code: public static void main(String args[]) { // While loop set-up boolean flag = true; while (flag) { Scanner sc = new Scanner(System.in); // Ask user to enter employee number System.out.print("Enter employee number: "); int employee_number = sc.nextInt(); // Ask user to enter last name System.out.print("Enter employee last name: "); String last_name = sc.next(); // Ask user to enter number of hours worked System.out.print("Enter number of hours worked: "); int hours_worked =...
My Java code from last assignment: Previous Java code: public static void main(String args[]) { // While loop set-up boolean flag = true; while (flag) { Scanner sc = new Scanner(System.in); // Ask user to enter employee number System.out.print("Enter employee number: "); int employee_number = sc.nextInt(); // Ask user to enter last name System.out.print("Enter employee last name: "); String last_name = sc.next(); // Ask user to enter number of hours worked System.out.print("Enter number of hours worked: "); int hours_worked =...
(TCO 1) The JVM executes a Java application by (Points : 6) executing the public static main method of the class. creating an object of the class and executing that object’s main method. executing the class constructor. compiling the Java code into byte code. (TCO 1) Which method call converts the value in variable stringVariable to a double? (Points : 6) Double.parseDouble( stringVariable ); Convert.toDouble( stringVariable ); Convert.parseDouble( stringVariable ); Float.parseFloat( stringVariable ); (TCO 1) Which of the following can...
In JAVA Algorithm Workbench 1. Write the first line of the definition for a Poodle class. The class should extend the Dog class. 2. Look at the following code, which is the first line of a class definition: public class Tiger extends Felis In what order will the class constructors execute? 3. Write the statement that calls a superclass constructor and passes the arguments x, y, and z. 4. A superclass has the following method: public void setValue(int v) value...
(PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE OR THE OTHER) Design an Employee class that fields for the following pieces of information: 1) Employee name 2) Employee number Next design a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to hold the following information: 1) Shift number (an integer, such as 1, 2, or 3) 2)Hourly pay The workday is divided into two shifts day...
(PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE OR THE OTHER) Design an Employee class that fields for the following pieces of information: 1) Employee name 2) Employee number Next design a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to hold the following information: 1) Shift number (an integer, such as 1, 2, or 3) 2)Hourly pay The workday is divided into two shifts day...
In Java Which of the following statements declares Salaried as a subclass of payType? Public class Salaried implements PayType Public class Salaried derivedFrom(payType) Public class PayType derives Salaried Public class Salaried extends PayType If a method in a subclass has the same signature as a method in the superclass, the subclass method overrides the superclass method. False True When a subclass overloads a superclass method………. Only the subclass method may be called with a subclass object Only the superclass method...