For the GeometricObject and Circle classes in Listings 11.1 and 11.2, answer the following questions:
a. Assume that circle and object1 are created as follows:
Circle circle = new Circle(1);
GeometricObject object1 = new GeometricObject();
Are the following Boolean expressions true or false?
(circle instanceof GeometricObject)
(object instanceof GeometricObject)
(circle instanceof Circle)
(object instanceof Circle)
b. Can the following statements be compiled?
Circle circle = new Circle(5);
GeometricObject object = circle;
c. Can the following statements be compiled?
GeometricObject object = new GeometricObject();
Circle circle = (Circle)object;
Want to see the full answer?
Check out a sample textbook solutionChapter 11 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Additional Engineering Textbook Solutions
Starting out with Visual C# (4th Edition)
Software Engineering (10th Edition)
Digital Fundamentals (11th Edition)
Absolute Java (6th Edition)
Problem Solving with C++ (10th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
- Java- Suppose that Vehicle is a class and Car is a new class that extends Vehicle. Write a description of which kind of assignments are permitted between Car and Vehicle variables.arrow_forwardSolve:arrow_forwardusing c++ oop !!! kindly need help asap. Implement the shape, rectangle, and square classes with components as shown and the following functionality: Each constructor and destructor prints a message to the screen that it is being called in each class implement the area() method that calculates the area of the figure (for the Shape class you can return 0) Example Constructor shape: Rectanleeeeeee Rectangle constructor 232.5 Rectanleeeeeee Eeeeeeee Rectangle destructor Shape destructor Constructor shape: Squareeeee Rectangle constructor Square constructor Squareeeee AAAaaaa 105.165 Square destructor Rectangle destructor Shape destructor // main.cpp : Defines the entry point for the application.// #include "main.h"using namespace std; int main(void) {{rectangle rec("Rectanleeeeeee", 10, 23.25);std::cout << rec.area() << std::endl;std::cout << rec.get_name() << std::endl;rec.set_name("Eeeeeeee");std::cout << rec.get_name() << std::endl;} {square…arrow_forward
- please solve it with java and put screenshots of the codearrow_forwardPart 1: Abstract Classes 1. Copy the source files of Circle, Rectangle and GeometricObject classes (located in LabFiles folder) and paste them in the default package (You may need to fix any problems related to package declaration). 2. Open Circle, Rectangle and GeometricObject classes using NetBeans editor and go through the classes’ implementation. 3. In the GeometricObject class add two methods called respectively getArea() and getPerimeter(). Discuss: 1. Is the area formula of a circle similar to area formula of a rectangle? Since: GeometricObject is the superclass of Circle and Rectangle, and getArea() method is a common method in both Circle and Rectangle classes. Then: 2. Should you define the getArea() method in the superclass GeometricObject? Or in the subclasses Circle and Rectangle? 3. If yes, Should the getArea() method be declared as abstract method in the superclass GeometricObject? Or as instant method? 4. Is declaring getArea() as abstract, would solve…arrow_forward(1) Extend the ItemToPurchase class to contain a new attribute. item_description (string) - Set to "none" in default constructor Implement the following method for the ItemToPurchase class. print_item_description() - Prints item_description attribute for an ItemToPurchase object. Has an ItemToPurchase parameter. Ex. of print_item_description() output: Bottled Water: Deer Park, 12 oz. (2) Build the ShoppingCart class with the following data attributes and related methods. Note: Some can be method stubs (empty methods) initially, to be completed in later steps. Parameterized constructor which takes the customer name and date as parameters Attributes customer_name (string) - Initialized in default constructor to "none" current_date (string) - Initialized in default constructor to "January 1, 2016" cart_items (list) Methods add_item() Adds an item to cart_items list. Has parameter ItemToPurchase. Does not return anything. remove_item() Removes item from cart_items list.…arrow_forward
- 1 - Student class Make a class student (in student.py) that stores the following information for a student: Name (name) Student number (student_nr) Points per assignment (points_per_assignment) Exam grade (exam_grade) a) Behind each point of information is the name of the parameter to the initializer method. Store this information from the parameters in the object attributes with the same name. b) Add a method course_points() which returns the number of course points the student has gotten. Example: mary = Student("Mary", 15789613, [10, 9, 8, 10, 9, 10], 9)print(mary.course_points()) > 121 The calculation of the course points is explained in the course overview, course setup slides (Links to an external site.) and the first lectureLinks to an external site.. c) Add a method grade() which returns a the final grade of the student, rounded to nearest half (upwards, 6.75 -> 7). As per regulations, a 5.5 becomes a 6. If the student did not pass both the assignments (>= 95…arrow_forwardNovice: How can i access a main class objects from outside the function? / Better Alternative? If i have 4 Student objects how can i print the information for the specific object given one parameter about the class, like the students Idnumber. What i came up with was making a checkId void function that takes the user input and runs an if else chain checking if the Id belongs to student 1-4 then printing the details of that classes object with the void function print. ideally i would want the if-else chain in the checkId function to call the print( student1-4) class object but im not sure how to properly do that. i dont think this is the best way to go about it, if you have any recommendations or alternatives please help me out.arrow_forwardConsider: class Automobile { } What happens if you try to run: ? new Automobile(); Nothing happens It does not run A new class is created A new object is createdarrow_forward
- in C++arrow_forwardJava Program The assignment requires two classes. Put all classes in the same package. Class Employee Attributes (all private): id: String lastName: String firstName: String salary: int Methods: Parameterized constructor for initializing a new Employee instance Getters for all attributes toString method to display an Employee's attributes (See output of executable below) Executable Class Create an array of at least eight Employee objects. Be sure to use many with identical last names, but don't order them by name in the array. Create an ArrayList from the array. Sort the ArrayList first by last name and then by first name. Using the forEach method and a lambda expression, print all employees alphabetically sorted by name. Create a LinkedList from the ArrayList. Create an iterator capable of cycling both forward and backward through the LinkedList. Iterate forward through the LinkedList without generating any output. Then iterate backwards through the LinkedList to print…arrow_forwardUrgent Quick Question Write an equals method for the StepsFitnessTracker class that tests whether the one object is equal to another object that is passed as an argument (Object otherObject). The Object superclass provides an equals method that tests if two object references are equal. Your new equals method should override the Object equals method, and should test the following: • Return true if the current (this) object, and otherObject are identical references (hint: you can use the == operator for this). • Returns false if otherObject is null. • Returns false if the current (this) object and otherObject have different classes (hint: you can use the getClass() method provided by the Object superclass, see the Java 8 API documentation for details). • Casts otherObject to a StepsFitnessTracker, and tests for equality of each instance variable1 , if the instance variables are the same the method should return true. Now write an equals method for the DistanceFitnessTracker and…arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,