.e., “cnic” of type integer and “name” of type String, and a setter and getter method of type void and integer respectively that sets and returns the name state. An object of class Citizen is created in another class that holds main method. Explain what size is reserved for both classes in
Q: A constructor can specify the return type O a. class type O b. int O . None of the answers O d. void…
A: Solution to the above question: 1) c) None of the answers. In any Object oriented programming…
Q: Write a JAVA program to create an array of objects of a class student. The class should have field…
A: Java is a programming language. It contains extensive libraries (package). It can be used to create…
Q: Consider a class that keeps track of the sales of an item. An object of thisclass will have the…
A: Given : Consider a class that keeps track of the sales of an item. An object of this class will have…
Q: 3. Provide an example of how to achieve encapsulation in Java. 4. Is it possible to declare abstract…
A: 3) Encapsulation is the process of keeping the data and code together inorder to provide security.…
Q: Define a new "Degree" class that contains a year (integer), a subject (string) and a person's name…
A: Hey there, I am writing the required solution based on the above stated question. First, I will…
Q: Question 5 a. After the introduction of classes, in a java class, Adongo a student of the class came…
A: a) class Abelewas {void bankudade();int fabewoso();double AttaaAyi(int x);}class pepper extends…
Q: 11. Implement a class to represent a playing card. Your class should have the following methods:…
A:
Q: mplement a class Quiz that implements the Measurable interface. A quiz has a score and a letter…
A: Measurable.java/** * Describes and class whose objects can be measured */ public interface…
Q: Consider the following class Date, which represents a date using three ints for month, day and year:…
A: bool Date::operator==(Date d){ if (month == d.month && day == d.day && year ==…
Q: Design a Java class named LinearEquation for a 2-by-2 system of linear equations: ax + by = e…
A: the code is given below: given: The class contains:• Private double data fields a, b, c, d, e, and…
Q: Consider the following inheritance hierarchy: class A{ protected: int x, y; public: int z; };…
A: A) Class B has inherited class A privately. Thus all the protected data member of A will be…
Q: Python: implement a class called point, the class contains two values of a type of integer (x and…
A: The main objective of the program is to create a point class. The point class has two variables x…
Q: Given a class Square with an instance variable width, provide a recursive getArea method. Construct…
A: public class Main{ public static void main(String[] args) { new Square(5).getArea(); //create…
Q: P9.8 Implement a superclass Person. Make two classes, Student and Instructor, that inher from…
A: //Instructor.java public class Instructor extends Person { private double salary; public…
Q: Consider a class PersonAddress that represents an entry in an address book. Its attributes are The…
A: ANSWER:-
Q: b) Write a java program to create an abstract class named Shape that contains two integers and an…
A: b. Algorithm: Start Create a shape abstract class with two data members and a method printArea()…
Q: Define a class
A:
Q: Please dont copy and paste and give proper explanation. Suppose that a Java implementer is required…
A: // the parent class class Person { // general member variables String firstname; String…
Q: Write is the output of the following program with explanation? interface A { } class C
A: interface A { } Interface is called as blueprint of a class by default all the methods are abstract…
Q: Below we have class diagrams with three classes for a simple java based parking management class.…
A: Solution - For a parking management system, use the Observer pattern to implement this interaction…
Q: i. Create a generic class with a type parameter that simulates drawing an item at random out of a…
A: Note: The solution of the first subpart is shown below. Please repost the second subparts with the…
Q: Consider following code in Java language. public class X { MODIFIER int value = 3; }; Another class…
A: (a) Y subclasses X and is in the same package; Since y is a child class(subclass) of X, hence When…
Q: e in java 1. Create a class called Student, with the following attributes/variables: a. studentName…
A: We need to create the Student and MyFriends classes as per the given description.
Q: 2. Consider the following class definitions: public class BClass private int x; public void set(int…
A: Lets see the solution in the next steps
Q: In Java Language: Suppose we have a hierarchal relationship between : Fruit , Mango , Apple , and…
A: //Only class Fruit needs to have definition of method show() for this code to compile because the…
Q: Write a java program to complete the following parts: Part-1: Create a class Car and perform the…
A: According to the information given:- We have to follow the instruction mentioned to implement in…
Q: ollowing is correct? a. None of the other answers b. We know the name of its constructor(s) c. We…
A: Answer is given below-
Q: 1/ Implement a class Employee. An employee has a name (a string) and a salary (a double). Provide a…
A: Note: This is a multiple-question-based problem. The only first question is solved. Kindly send the…
Q: ontainsInRange. This class defines a method called contains(), which takes as parameters an integer…
A: Create class ContainsInRange. Define method contains to check the value x in array a in the range…
Q: Solve the programming exercise P9.9 on Page 490 on the book. Make a class Employee with a name and…
A: public class Employee{ //declaring instance variables private String name; private double…
Q: ) Implement a class Point with three attributes, x, y, and z. b) Implement an init method with an…
A: GIVEN: Create a program for the above question. NOTE: As programming language is not mentioned, we…
Q: Write a Java program that defines a Shape class having an abstract method draw(). Inherit Rectangle,…
A: Java program that defines a Shape class having an abstract method draw(): import java.util.* ;…
Q: class A {protected int x1,y1,z; public: A(a, b,c):x1(a+2),y1(b-1),z(c+2) { for(i=0; i<5;i++) x1++;…
A: Answer: x1 -> 11, y1 -> 2 and z -> 8
Q: 53. Write a class with two instance variables, representing an old password and a new password.…
A: Since no programming language is mentioned, I am using java Code: class Client{ private String…
Q: Read the quistion entirely before ansewring the code should compile and run Create a java class…
A: import java.util.Scanner;import java.util.*;import java.lang.*;public class Question2{public void…
Q: class A {protected int x1,y1,z; public: A(a, b,c):x1(a+2),yl(b-1),z(c+2) { for(i=0; i<5;j++) x1++;…
A: Answer: x1 -> 11, y1 -> 2 and z -> 8 See below step for explanation.
Q: Use Netbeans to run the following decorator pattern code. Provide screenshot to prove that the code…
A: Firstly, open the Netbeans IDE. Steps to create a project with the name spaceship: Go to new->…
Q: Write a java program in which A class named Processor has Two public attributes i.e. price and…
A: Given: Write a java program in which A class named Processor has Two public attributes i.e. price…
Q: Import Class a) Implement a class Rectangle with two attributes, width and height. b) Implement an…
A: Note: Answering the first three subparts as per the guidelines. Task : Define class name Rectangle…
Q: Write in java: Define a class called Country. A Country has populationSize, area, capital,…
A: given data Write in java: Define a class called Country. A Country has populationSize, area,…
Q: 5) Consider the Clock class, which represents the passage of time. The tick() method adds one minute…
A: Consider the Clock class, which represents the passage of time. The tick() method adds one minute to…
Q: Solve the programming exercise P9.8 on Page 490 on the book. Implement a superclass Person. Make two…
A: // Screenshot of the code & output
Q: In Python without using super(): Given the base class Book, define a derived class called…
A: class Book: def __init__(self, title, author, publisher, publication_date): self.title =…
Q: Write Java program for given scenarios below: Create a class named 'Member' having the following…
A: Program with commented explanation, code and output is below. Member class is a parent/super class.…
Q: Given the following code (where the function FunTest() and the main method are inside one class in…
A: Given Code: class Q13{ public static void FunTest(Object obj1){ Z z1=(Z)obj1;…
Q: Write a Java program that defines a Shape class having an abstract method draw(). Inherit Rectangle,…
A: Code: import java.io.*; import java.util.*; //Abstract Shape class having an abstract method…
Q: we have a hierarchal relationship between : Fruit , Mango , Apple , and Orange . Assume that you see…
A: It is defined as a data model in which the data are organized into a tree-like structure. The data…
Q: Q1. Write two Java classes for calculating the power m" using the recursive method as follow: Class…
A: Algorithm to calculate power mn using recursion: Method: int calculatePower(n, m) 1. IF n == 1:…
Q: Implement the following classes and interface in Java. • Shape interface which has the following…
A: public interface Shape { //interface declaration //declaring methods public double perimeter();…
JAVA OOP
Class Citizen holds two states i.e., “cnic” of type integer and “name” of type String, and a setter and getter method of type void and integer respectively that sets and returns the name state. An object of class Citizen is created in another class that holds main method.
Explain what size is reserved for both classes in the memory.
Step by step
Solved in 2 steps
- Write the code below for the Computer class. The Computer class must be an abstract class, and have the following methods and attributes: • a public string called HostName • a private int called MemorySize • a public abstract method called shutdown that takes no arguments and returns nothing • a public abstract method called runProgram that takes a String for the name of the program and returns a boolean. • Also include getter/setter methods for the attributesDesign a Java class that is named as MyInteger. The class should contain: An int data field named value that stores the int value represented by this object. A constructor that creates a MyInteger object for the specified int value. A getter method that returns the int value. The methods isEven(), isodd(), and isPrime () that return true if the value in this object is even, odd, or prime, respectively. The static methods isEven(int), isodd(int), and isPrime (int) that return true if the specified value is even, odd, or prime, respectively. The static methods isEven(MyInteger), isodd(MyInteger), and isPrime(MyInteger) that return true if the specified value is even, odd, or prime, respectively. The methods equals (int) and equals(MyInteger) that return true if the value in this object is equal to the specified value. E A static method parseInt (char[]) that converts an array of numeric characters to an int value. A static method parseInt (String) that converts a string into an int…Design a Java class that is named as MyInteger. The class should contain: An int data field named value that stores the int value represented by this object. A constructor that creates a MyInteger object for the specified int value. A getter method that returns the int value. The methods isEven(), isOdd(), and isPrime() that return true if the value in this object is even, odd, or prime, respectively. The static methods isEven(int), isOdd(int), and isPrime(int) that return true if the specified value is even, odd, or prime, respectively. The static methods isEven(MyInteger), isOdd(MyInteger), and isPrime(MyInteger) that return true if the specified value is even, odd, or prime, respectively. The methods equals(int) and equals(MyInteger) that return true if the value in this object is equal to the specified value. A static method parseInt(char[]) that converts an array of numeric characters to an int value. A static method parseInt(String) that converts a string into an int value. Write…
- 10. Java automatically applies the method to an object referenced in a String expression to represent an object’s state. a. toString () b. abstract c. super() d. this() 11. The call in a class constructor invokes the superclass's constructor that has the corresponding argument list. a. tostring () b. abstract c. super() d. this() 12. The call to invokes the constructor for the current class whose parameter list matches the argument list. a. toString () b. abstract c. super() d. this() 13. If no constructors are defined for a class, the constructor for that class will be provided by default. a. private b. super c. public d. no-argument 14. What is a keyword to declare a subclass to a super class in Java? a. implements b. extends c. throws d. followsPlease help with the following: C# .NET change the main class so that the user is the one that as to put the name in other words. Write a driver class that prompts for the person’s data input, instantiates an object of class HealtProfile and displays the patient’s information from that object by calling the DisplayHealthRecord, method. MAIN CLASS---------------------- static void Main(string[] args) { // Instance created holding 6 parameters which are field with value HealthProfile heartRate = new HealthProfile("James","Kill",1978, 79.5 ,175.5, 2021 ); heartRate.DisplayPatientRecord();// call the patient record method } CLASS HeartProfile------------------- public class HealthProfile { // attibutes which holds the following value private String _FirstName; private String _LastName; private int _BirthYear; private double _Height; private double _Weigth; private int _CurrentYear; public HealthProfile(string firstName, string lastName, int birthYear, double height, double wt, int…In java please help with the following: Consider given the FileProcessor a class. Because this class locks some computer resources it is required that this class is instantiated only once. Using singleton design pattern create an application (create all necessary classes and implement the application main method) that will enforce the unique instantiation of the given class.
- Java Object Oriented Programming Create a Shape class that shall have color and filled instance variables of enum Color and boolean type. The filled boolean variable shall show, whether the shape is filled (colored). The enum Color shall be defined within the class having 4 color names (choose any four). Also define getArea and getPerimeter method in Shape class, both shall return 0. Create Rectangle class with length and width attributes and a Circle class with radius attribute, of type double. Properly encapsulate all fields. Circle and Rectangle shall extend Shape class and override getArea and getPerimters methods as per its type and specific formula. In Test class, create an object of Rectangle and Circle, by initializing all attributes in constructor and print both shapes' area and perimters. In Test class, define a static method with following signature, public static void printEachShapeCount(Shape... shapes) As you know, the parent type variable can hold the…Create a complete Java class that can be used to create a Computer object as described below:A Computer has a:- Manufacturer- Disk Size- Manufacturing Date- Number of coresa) Add all instance variables (data encapsulation is expected).b) The class must have getters and setters for all instance variables.c) The class must have two constructors: a no-arg constructor and a constructor thatreceives input parameters for each instance variable.d) Implement a toString() method for your class.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.
- Define a java Name class with attributes: String firstname, middle name, lastname. Include the following methods: - A constructor with 3 parameters. Initialize the 3 member variables to the parameters being passed. Also, include the default constructor. - getter and setter methods for all attributes - override toString method Define a class called DebitCard. A debit card has a card number, Name and balance. a) Include a constructor with 3 parameters. Initialize the 3 member variables to the parameters being passed. Also, include the default constructor. b) Include getters/setters for all attributes. c) Add the following member functions: float inquireBalance() float depositCash(float amount) //increases the balance with amount boolean withdrawCash(float amount) // returns true if sufficient amount is available for withdrawal and decreases the balance by amount float interest(float rate) //calculates the interest rate incurred. Assume the parameter rate is considered as…Define a class Student to create Student Objects. The class defines two variables for its objects: name (String ) and average (double). The class provides a constructor with arguments and includes the following object methods to do the following: - public void print() : prints the Student data - public void setAverage(double newAvergae): sets the student average with a new value. Define a class StudentTest In the main method, create three student objects (Ali, Rami, Khalid) with initial average 60 for each one. - Call the setAverage method on each created student to change their average with a randomly value (hint: use Math.random( ) method to generate average value in range [0..100]). - Print the name of the student who's the maximum average. hint: you should compare between the Student objects according to their average.Define a java Name class with attributes: String firstname, middle name, lastname. Include the following methods: - A constructor with 3 parameters. Initialize the 3 member variables to the parameters being passed. Also, include the default constructor. - getter and setter methods for all attributes - override toString method Define a class called DebitCard. A debit card has a card number, Name and balance. a) Include a constructor with 3 parameters. Initialize the 3 member variables to the parameters being passed. Also, include the default constructor. b) Include getters/setters for all attributes. c) Add the following member functions: float inquireBalance() float depositCash(float amount) //increases the balance with amount boolean withdrawCash(float amount) // returns true if sufficient amount is available for withdrawal and decreases the balance by amount float interest(float rate) //calculates the interest rate incurred. Assume the parameter rate is considered as…