Which of the following statements are true? Group of answer choices 1. A superclass reimplements the functionality of its subclasses. 2. A class that implements an interface reuses the functionality of the interface. 3. A derived class reuses the functionality instead of reimplements it. 4. If a class has no bugs, we can inherit from it without fear of having any bugs in our class.
Q: Create a class named 'Member' having the following members: Data Attributes of Member Class 1- Name…
A: class Member: def Member_detail(self): self.__name = input("Enter Name: ") self.__age =…
Q: Which Option is false about final classes
A: FINAL CLASS - A class is said to be final class if it we add final keyword before declaring a…
Q: Fill in the blank space 1. The ____________ keyword is used to create a new instance or object of…
A: Complete the following sentences with a proper answer, 1. The ____________ keyword is used to create…
Q: 9. Which of the following is FALSE about a subclass? A. A subclass has overridden methods from the…
A: Q19. subclass: the derived class (a class which is derived from another class) is known as the…
Q: Which of the following is/are TRUE for class in C++? (You may choose more than pne answers)…
A: Answer:
Q: Write a java code that: a) Creates an abstract method in a superclass, then overrides it in a…
A: a) abstract class Animal { abstract void makeSound(); public void eat() {…
Q: Which of the following reasons for using an inheritance hierarchy are valid? (Select all that apply)…
A: We need to select the correct statements that are valid reasons for using an inheritance hierarchy.…
Q: What do we means by class interface. Write a small piece of code to explain class interface
A:
Q: rentiate between early binding and late binding. (Write in maximum 5 lines) [5 Marks] b. Write a…
A: Explanation: (A) Binding is the process of creating a link between a method call and method…
Q: Create an abstract NewspaperSubscription class with fields for the subscriber name, address, and…
A: Here, I am giving detailed explanation of the program
Q: A reference to a superclass cannot be used to point to an object of a subclass. Is this statement…
A: False A reference to a superclass cannot be used to point to an object of a subclass. Is this…
Q: QUESTION 9 What are the different visibility modifiers? Differentiate between them. QUESTION 10…
A: 9. The visibility modifiers are listed below: Public Protected Private Default or internal
Q: 15 Which of the following is not possible? O A class that implements two interfaces. O A class that…
A: Answer: Class: Classes and Objects are the simple components of OOP's. Class are a blueprint or a…
Q: Part A: Create a class named Insect, which includes the following: 1. Attributes including:…
A: Two classes Insect and Butterfly in which Butterfly class inherited from the Insect class,…
Q: 1. Create (the package) as (P1) and another as (P2). 2. Create an Interface (named Human) inside…
A: A class is the building block of object oriented modelling. It contains data and operations on that…
Q: Create an interface relational interface relational { void greaterThan(); void lessThan(); void…
A: In Java, an interface is a template for a class. It has abstract methods and static constants. In…
Q: (Keeping mutables safe) Suggest a simple scheme for creating a new classSafeMember that would allow…
A: Mutable safe class or immutable class means after creating an object the value of it cannot be…
Q: Create an interface OnlineQuiz with the following details: Member variables: 1. maxMarks-10 Member…
A: In Java, an interface is a template for a class. It has abstract methods and static constants. In…
Q: 1. Show PolynomialADT interface 2. Create the PolyNodeClass with the following methods: default…
A: public class PolyNode { private int coefficient, exponent;private PolyNode next; public PolyNode()…
Q: Assume you have a method expecting the superclass's object to be passed as an argument. In this…
A: In Java, all non-static methods are based on the runtime type of the underlying object rather than…
Q: Which of the following does NOT apply to the strategy design pattern? It can change the behavior of…
A: Please find the answer below :
Q: User: Make a class called User. Create two attributes called first name and last_name, and then…
A: User.java class User{ private String first_name; private String last_name; //constructor for…
Q: If you assign a new instance of a subclass object to a super-class variable without casting, what…
A: This involves the concept of Inheritance in object oriented programming.
Q: Create an interface OnlineQuiz with the following details: Member variables: totalMarks=10 Member…
A: Note- Answering the first question as per the guidelines. The following is the interface created in…
Q: Interfaces are used to define stronger is-a relationships because one class can inherit multiple…
A: A class is able to implement more than one interface, which contains default methods that have the…
Q: What is code refactoring?
A: Answer: option B is correct: Because code refactoring says modify the internal code without changing…
Q: Create a subclass named Square from the superclass GeometricObject. Create an instance variable…
A: GeometricObject.java public abstract class GeometricObject {private String color = "white";private…
Q: 1. Create (the package) as (P1) and another as (P2). 2. Create an Interface (named Human) inside…
A: A class is the basic building block of object oriented modelling. It has data and operations on that…
Q: hich of the following statement is not true? An anonymous inner class is compiled into a class…
A: A) True : An anonymous inner class is compiled by a class named OuterClassName$n. For example, if…
Q: Pick the incorrect statement: O A class can implement more than one interface O A class can extend…
A: Extends keyword to include a class (indicates that a class is inherited from another class). In…
Q: Qn 1) Use only Python Programming language for the below question. Someone made the following class:…
A: Code: class Address: def __init__(self,street,num): self.street_name=street…
Q: User: Make a class called User. Create two attributes called first_name and last_name, and then…
A: Step 1:- Note:-I am writing the program in the python language because there is no programming…
Q: Create a subclass named Square from the superclass GeometricObject. Create an instance variable…
A: Sub Class is a class which inherits the other class. It is also called a derived class or child…
Q: Create a project Vehicles in bluej. The project has Cars, Buses ,Trucks and Bikesclasses ,all these…
A: Programming is instructing a computer to do something for you with the help of a programming…
Q: Create a subclass Person from an abstract class Name. The Name class has two attributes first name…
A: public abstract class Name //declaring abstract class{ //declaring attributes private String…
Q: 1. Which of the following is NOT true about encapsulation? * Loosely called "information hiding"…
A: Find the answer with explanation given as below :
Q: Write a program using the concept of interface to do the following. a) Create an interface Student…
A: import java.util.Scanner;interface Student{ //Interface named Student…
Q: A superclass Person contains: 1. Three instance variables: name, address, age. Constructor with the…
A: Answer: Our instruction is answer the first three part from the first part and I have done code and…
Q: If you assign a new instance of a subclass object to a super-class variable without casting, what…
A: Let us see the answer,
Q: which application of oop can be provide a degree of freedom in the * :interface design option…
A: Friend functions provide a degree of freedom in the interface design option. This function is used…
Q: What is the concept of binding? Differentiate between early binding and late binding. (Write in…
A: Binding is a process that establishes a link between the procedure call and the actual…
Q: Which statement is true? Question 14 options: An abstract method is a method that appears in a…
A: Answer to the above question about true statements of Abstract method is in step 2.
Q: 1. If there are one or more constructors for a class then how many constructors will be called when…
A: Given: AS PER OUR POLICY “Since you have posted a question with multiple sub-parts, we will solve…
Q: Which of the following is wrong? The Object class is a superclass of all other classes. O A variable…
A: All class and array types may or may not inherit the methods of class Object. So this falls under…
Q: Design an interface named Encryptor that has a single (abstract) method named encrypt with one…
A: HERE IS THE STEP-BY-STEP CODE SNIPPET : CODE: // Encryptor.java // EncryptorOne.java //…
Q: Assume you have three interfaces I1, I2 & I3. The definition of these three interfaces is given…
A: The Following scenario is implemented in Java. The user can use any other language just change the…
Q: When should you use an abstract class? Group of answer choices 1. All options are correct. 2.…
A: Answer: when abstract class use then two or more classes can share identical method so option 2 is…
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Which (if any) of the following conditions are necessary for using polymorphism? Select all correct answers. The classes involved are in the same hierarchy. None of the classes can be abstract. All of the subclasses involved override the same method. The object reference cannot be of an interface type. An object reference of the superclass is used to call any methods. A superclass object is referenced by a subclass reference. Which of the following (if any) are true of abstract methods? Select all correct answers. Abstract methods must have a method body. Abstract methods cannot be declared in a class that isn't abstract itself. Abstract methods cannot be private or static. Abstract methods can only be declared in an interface. Abstract methods cannot be called. Constructor methods can be abstract.Which (if any) of the following conditions are necessary for using polymorphism? Select all correct answers. The classes involved are in the same hierarchy. None of the classes can be abstract. All of the subclasses involved override the same method. The object reference cannot be of an interface type. An object reference of the superclass is used to call any methods. A superclass object is referenced by a subclass reference. Which of the following (if any) are true of abstract methods? Select all correct answers. Abstract methods must have a method body. Abstract methods cannot be declared in a class that isn't abstract itself. Abstract methods cannot be private or static. Abstract methods can only be declared in an interface. Abstract methods cannot be called.Fill in the blank space 1. The ____________ keyword is used to create a new instance or object of a class 2. ______________ is the concept of closely controlling access to an object's attributes and is also called information hiding 3. A ____________ is a method that is used 5o set the initial state of an object when it is created. 4. (i) Method _________ is the process of changing the number and type of parameters of a method (ii) Method __________ is the process of replacing a method in a superclass with a new implementation in the subclass 5. A ______________ expression is an expression that evaluates to either true or false. 6. In Java polymorphism means that a class or object can be treated as multiple different types. Which of the following statements regarding polymorphism in Java are true? Select all that apply. A. A subclass can be treated as any of it's ancestor (super) classes. B. A Java class can be treated as any interface it implements C. A Java class can be treated…
- Which of the following statement is not true? An anonymous inner class is compiled into a class named OuterClassName$InnerClassName.class An anonymous inner class must always extend a superclass or implement an interface, but it cannot have an explicit extends or implements clause. An anonymous inner class always uses the no-arg constructor from its superclass to create an instance. If an anonymous inner class implements an interface, the constructor is Object(). An anonymous inner class must implement all the abstract methods in the superclass or in the interface.Write a class named Employee which implements Comparable Interface with name and salary as data field. Add a constructor with argument name and salary. Add getter and Setter for name and salary. Add CompareTo() method for the data Name. Write a class named Manager which inherits the Employee class. Add an instance variable, named department, of type String. Add a constructor in the subclass class with arguments name, salary, department and a toString() method that prints the manager’s name, department, and salary [Hint: Add a toString( ) method in the super class as well] Create 3 objects of Manager with following arguments 1. (Zayed, 500), 2. ( Ahmed, 700) 3. ( Faisal, 600) Create an Array object Add the above 3 objects into an Array object and Sort by Name and Display Create an object Employee class with argument (Zayed, 500, IT) Display the 1. Name 2. Salary 3. Department by using tostring() method.Part A: Create a class named Insect, which includes the following: 1. Attributes including: a. A String named species b. A double named weight 2. Get and Set methods for both attributes 3. A default constructor that initializes species to "NA" and weight to 0.0 4. A non-default constructor that takes a String and double argument and defines the corresponding attributes as those values. 5. A method named eat, which increases the weight by 1. Part B: Create a subclass of the class Insect named Butterfly. 1. Include another double attribute named maxWeightToFly 2. Include get and set methods for this new attribute 3. Include a default constructor that initializes species to "NA", weight to 0.0, and maxWeightToFly to 0.0 4. Include a non-default constructor that takes a String and two double arguments and defines the corresponding attributes to those values. 5. Override the eat method so that it increases the weight by 0.5 instead of 1 6. Include a new method named isAbleToFly…
- Write a class named Employee which implements Comparable Interface with name and salary as data fields Add a constructor with argument name and salary. Add getter and Setter for name and salary. Add CompareTo() method for the data Salary. Write a class named Manager which inherits the Employee class. Add an instance variable, named department, of type String. Add a constructor in the subclass class with arguments name, salary, department and a toString() method that prints the manager’s name, department, and salary [Hint: Add a toString( ) method in the super class as well] Create 3 objects of Manager with following arguments 1. (Zayed, 500), 2. ( Ahmed, 700) 3. ( Faisal, 600) Add the above 3 objects into an ArrayLIst object and Sort by Salary and Display. Create an object Employee class with (Zayed, 500,IT) and display the 1. Name 2. Salary 3. Department by using tostring() method.True or False ___(7) An object can be created from an interface. ___(8) An object in a super class can be assigned to a subclass variable. ___(9) Overriding and overloading a method is the same.1)In the C++ code segment below, which of the following are valid reasons for making vUnit a member of myClass2? class myClass1 { //other details omitted}; Class myClass2 { myClass1 vUnit; //other details omitted}; A)It allows for polymorphism. It models a has-a relationship in myClass2 to myClass1. B)It uses less memory that inheritance. C)It is a short-hand notation for inheritance. D)It gives myClass2 faster access to myClass1 than could be achieved via inheritance. 2)which of the following represent valid use cases of the ANSI C register storage class specifier? A)A for loop in which the loop index is declared in the initialization. B)A short int inside a block which will be passed by pointer to another function. C)An unsigned short defined inside a function combined with other quantities as a bitmask. D)A parameter list of an external function declared in a header file. E)A char array declare at file…
- Use the code provided copied to a new file named compulsory_task_1.py: 1. Add another method in the Course class that prints the head office location: Woodstock, Cape Town2. Create a subclass of the Course class named OOPCourse3. Create a constructor that initialises the following attributes and assigns these values: --- "description" with a value "OOP Fundamentals" --- "trainer" with a value "Mr Anon A. Mouse"4. Create a method in the subclass named "trainer_details" that prints what the course is about and the name of the trainer by using the description and trainer attributes.5. Create a method in the subclass named "show_course_id" that prints the ID number of the course: #123456. Create an object of the subclass called course_1 and call the following methods contact_details trainer_details show_course_id These methods should all print out the correct information to the terminal On a side note, this task covers single inheritance. multiple inheritance is also…Please complete the following tasks: Write a class “Actor” that contains two attributes with the appropriate level of visibility explicitly defined. “Name” which is a String, Private, “NumberofAwards” which is an integer, private Write a default Constructor for this class that initializes the name to “Bob Smith” , and the number of awards to 0. Write an overload the constructor for this class that accepts actor’s name as a parameter Write accessor methods for each of the attributes. Write a method “winsAnOscar” that increases the number of awards by one and prints “The crowd applauds for <actor’s name>!” Be sure to use accessors where appropriate. Make sure your header is complete, with the appropriate level of visibility and any required keywords.1. Which of these are ways you could refer to original and new class pairings? first class/second class parent/child base class/derived class superclass/subclass 2. We access both object and class attributes using dot notation True False 3. A function within a class definition is a(n) class function operation object function method 4. Objects have A value A type A reference count A unique ID 5. A class is a(n) _________ for an object Which of the following is not appropriate to fill in the blank? blueprint mold set of instructions accessor 6. A____could be thought of as a mold that creates objects