Please find your answers below. Let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks
Question 1:
Answer: MyClass#
Because special symbols except underscore (_) are not allowed in identifiers.
Question 2:
Answer: Instance variables are defined inside instance methods.
This is absolutely wrong since they are defined outside of all member functions.
Question 3:
Answer: Constructor can only be called using an object of that class.
This is wrong because constructors cannot be called using an object, it gets automatically invoked when an object is created
Question 4:
Answer: option d, public double FindSpeed(double d, double t){…}
This is wrong because constructor cannot have return types and neither do they return values.
Question 5:
Answer: The most possible answer is option a, which is below
Name: Mary Tweed Age:10
Name: Steve Smith Age:12
But there is also a problem, inside the method displayStudentDetails(), after “Name:”, there is no space at all. So the actual output should be like below.
Name:Mary Tweed Age:10
Name:Steve Smith Age:12
If this is deliberate, then the right option is “None of the above”
Question 6:
Answer: java.scanner
This is not a built in package. If you are thinking about Scanner class, it is located inside java.util package.
Question 7:
Answer: default
Question 8:
Answer: There are two answers for this. If you are calling this method from Rectangle class, both
double area = findArea(10.5, 5.5) ;
and
double area = Rectangle.findArea(10.5, 5.5);
are valid method calls. If you are calling from outside the Rectangle class, then only
double area = Rectangle.findArea(10.5, 5.5);
is valid.
Question 9:
Answer: An object can have at most one object reference pointing to it.
This is wrong, an object can have any number of object references.
Question 1 1 pts Which of the following is not a valid class name in Java?...
JAVA QUESTION 16 Write and submit the java source for the following class specification: The name of the class is Question_16 Class Question_16 has 3 instance variables: name of type String, age of type int and height of type double. Class Question_16 has the following methods: print - outputs the data values stored in the instance variables with the appropriate label setName - method to set the name setAge - method to set the age setHeight - method to set...
****Here is the assignment **** Purpose: To write an Object-Oriented application that creates a Java class with several instance variables, a constructor to initialize the instance variables, several methods to access and update the instance variables’ values, along with other methods to perform calculations. Also, write a test class that instantiates the first class and tests the class’s constructor and methods. Details: Create a class called Rectangle containing the following: Two instance variables, An instance variable of type double used...
Create a UML diagram to help design the class described in exercise 3 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Baby class object; should they be private or public? Determine what class methods are required; should they be private or public? Write Java code for a Baby class. A Baby has a name of type String and an age of type integer. Supply two constructors:...
Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the concept of a college course, assuming that a course has following attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the behavior of the class and its methods. The outline of the class is given as follows: public class Course...
Write a java class definition for a circle object. The object should be capable of setting radius, and computing its area and circumference. Use this to create two Circle objects with radius 10 and 40.5, respectively. Print their areas and circumference. Here is the Java class file (Circle.java). Compile it. public class Circle{ //Instance Variables private double PI = 3.1459; private double radius; //Methods public Circle ( ) { } //get method (Accessor Methods ) public double getRadius (...
Following is the EmployeeTester class, which creates object of the class Employee and calls the methods of that object. The EmployeeTester class is written to test another class: Employee. You are required to implement the class Employee by: declaring its instance variables: name, age, salary. implementing its constructor. implementing its methods: getEmployeeName(), getEmployeeAge(), getEmployeeSalary(), setEmployeeAge(int empAge), setEmployeeSalary(double empSalary) public class EmployeeTester { public static void main(String args[]) { // Construct an object Employee employeeOne = new Employee("Ahmad Abdullah"); //...
Java Program (PLEASE PROVIDE SCREENSHOT OF THE CODE) Create a class Person which is a super class. The class includes four private String instance variables: first name, last name, social security number, and state. Write a constructor and get methods for each instance variable. Also, add a toString method to print the details of the person. After that create a class Teacher which extends the class, Person. Add a private instance variable to store number of courses. Write a constructor...
Student is a class that has the following instance variables: name (a String), yearInSchool (an int), and gpa (a double). Write a constructor for the Student class that takes parameters for these instance variables as initial values of the variables. (in Java)
1. Create a UML diagram to help design the class described in Q2 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Person class object; should they be private or public? Determine what class methods are required; should they be private or public?2. Write Java code for a Person class. A Person has a name of type String and an age of type integer.Supply two constructors: one will be...
java This lab is intended to give you practice creating a class with a constructor method, accessor methods, mutator methods, equals method , toString method and a equals method. In this lab you need to create two separate classes, one Student class and other Lab10 class. You need to define your instance variables, accessor methods, mutator methods, constructor, toString method and equals method in Student class. You need to create objects in Lab10 class which will have your main method...