17 class A ( int i 3; public A(int i) ( What is the the output of the following code: D System.out.println (myMethod (i)); int myMethod (int i){ return i; class B extends A{ public B(int i, int j){ super (i*j): System.out.printin(super.myMethod (i)); int myMethod (int i) { return i*2; public static void main (String [ args) { B b = new B(2, 4);
Q: identify 8 Errors in the following code give a reason why .
A: Error 1: as method is static but return variable is not static. Error 2: as val variable is…
Q: public class MoneyWithdrawal { private double balance; public withdrawMoney (double amount) { /*…
A: In the given options there is no correct option for replacing the missing code
Q: use the following partial class definitions: public class A1 { public int x; private int y; public…
A: subclass (child) - the class that inherits from another class superclass (parent) - the class being…
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: Complete the following piece of java code (MyDate class). The semicolon after each method must be…
A: Question given: A piece of object oriented programming code is given. Complete this code by…
Q: 1. What is the output of the following program? Explain why? public class Boy{ int age = 10; }…
A: //lets trace the code for outputpublic class Boy{ int age=10;//data member}public class School{…
Q: 5. Given the definitions of class x (Figure 3) and class Y (Figure 4) below, class x { private int…
A: SolutionFigure 3 In line 2, create a class instance of name x In line 3, created an attribute of…
Q: Analyze the following code and choose the correct statement(s) about the following code (Choose all…
A: The this keyword refers to the current object in a method constructor. The most common use of the…
Q: Given the following code segments: class Programme{ b) private String name; private static int…
A: To Do: To write the above class in better design and pattern.
Q: c) Analyze the following pieces of code for "class A" and "class B". These pieces of code violate…
A: The given code is not following the proper object-oriented architecture. There are some flaws in the…
Q: Correct the following code fragment and what will be the final results of the variable a and b:
A: Consider the above code :
Q: Consider the following code: public class DemoClass{ private double PI = 3.1416; void…
A: class DemoClass{ final private double PI = 3.1416; // Use final such that PI can not be modified…
Q: Consider the following class defenition: 1. public class ClassA { 2. 3. private int[]] nums; public…
A: For the given java code, need to explain what will be the output :
Q: *a Given the following declaration of the class Foo, are the following valid or invalid ways to…
A: a) Foo f; This is the correct way declaration as this will call the default constructor the given…
Q: (i) Create an instance of FixedDeposit and display the annual interest for the instance that you…
A: Syntax for creating instance of class. className objectName=new className(); To call methods use…
Q: 大★: ** StopWatch class 大*
A: The program is implemented below in java language:
Q: Correct the following code fragment and what will be the final results of the variable a and b:…
A: Your correct code fragment is given below with an output.
Q: b) Given the following code segments: class Programme{ private String name; private static int…
A: A class is contains two types of members. Data members and methods.
Q: Instruction: Given the definition of methods and fields available to the Fraction class below,…
A: It is defined as programs can be asked from control statements, array, string, oops etc. Java basic…
Q: eSenior = 3; } Answer these questions according to the UML class schema and the code given above.…
A: [JAVA] public class FlightRules {public final static int minHostessCount = 2;public final static int…
Q: Which of the following best explains why the class will not compile? The class is missing an…
A: Liquid is the class provided for us It has two instance variables currentTemp and boilingPoint Along…
Q: ✓ Out of the following class declarations which one is/are invalid? (i) Class A { int x; }; (ii)…
A: Classes are an important concept of object-oriented programming. They are the way using which other…
Q: Question 4b What is the output? Full explain this question
A: Introduction: The concept of inheritance in Java refers to the transfer of properties from one class…
Q: 25 + BaseAmount; baseAmount+baseAmount; baseAmount = 2 * baseAmount; BaseAmount + 25;
A: which one of the following operations is not legal? 25 + BaseAmount; baseAmount+baseAmount;…
Q: use the following partial class definitions: public class A1 { public int x; private int y; public…
A: instance y of class A1 is private. and A derived class doesn't inherit access to private data…
Q: Carefully understand the code given bellow. Analyze the code and suggest any corrections needed with…
A: Correct C++ code: #include <iostream>using namespace std; class Student { //data members…
Q: (i) Class A { int x; }; (ii) Class B { } (iii) Public class A { } (iv) Object A { int x; };
A: As we know while creating any class its basic syntax is : Class A { private: int y;…
Q: Problem 1) The following Java Code class is given public class Point { private int xCor; private int…
A: public class Point { private int xCor; private int yCor; public Point(int x,int y) { this.xCor=x;…
Q: 1(c). what is the problem with the code below? Write two different ways to fix the problem.…
A: To Do: To tell the ways to fix the given codes.
Q: Analysis the following class definition and answer the following question. class Student{…
A: class Student{ private int id, age; protected float mark;…
Q: Which of the following classes correctly inherits from the below abstract class? public abstract…
A: Abstract class is a class whose object cannot be created. To access it we must use inheritance.
Q: A1. Find the output of the following code in order. public class Faculty extends Employee ( public…
A: Given: public class Faculty extends Employee{ public static void main(String[] args) {…
Q: a) What are the methods that can access the variable age b) What are the methods that can access the…
A: a)What are the methods that can access the variable age Answer:void calculate() b)What are the…
Q: Modify class Point to represent points in 3D instead of 2D.
A: In 3D, the dimensions are x, y, z So, we have to add data member for z-dimension
Q: Which of the following compiles without a problem? Why? a. product.discount = 20; b.…
A: private members are not accessible outside the class
Q: Correct the following code fragment and what will be the final results of the variable a and b:…
A: The Answer is
Q: About class member access illustrated in fig08_03: o Test this example code and explain why the…
A: private variables can be accessible only in the declared class But we have public method which can…
Q: Given below is the CRC diagram for a Circle ADT. Give the class definition and function definitions…
A: Program code: //define the class Circlepublic class Circle { //declare class member private…
Q: A1. Find the output of the following code in order. public class Faculty extends Employee ( E public…
A: One can use any one of the java compilers such as eclipse, Netbeans, or JDK in order to execute the…
Q: [CLO-4] Consider the following classes: package p1; public class Child extends Parent{ private int…
A: Find the required answer with explanation given as below :
Q: class Metov{ void sum(int i, int j){ System.out.println(i); } void sum(String c,String d){…
A: when the parameters are Strings, they got added which means appended and result is printed when the…
Q: c) Draw a UML Diagram for the following source code. (CLO1, CLO2) public class MyCircle { double…
A: Answer: UML diagram for given java program:
Q: Partial Question 3 Consider: class A { } public void doA() { } class B extends A { } public void doB…
A:
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…
Step by step
Solved in 2 steps with 1 images
- use the following partial class definitions:public class A1{public int x;private int y;public int z;…}public class A2 extends A1{public int a;private int b; …}public class A3 extends A2{private int q;…} 2) Which of the following lists of instance data are accessible in class A2?a) x, y, z, a, bb) x, y, z, ac) x, z, a, bd) z, a, be) a, bProblem 4) Suppose the following Course class is given: public class Course { private String name;//such as CS, MATH, etc private int grades[];//list of the grades //default and initial valued constructor //all other methods public double average() { double sum=0; for(int i=0;i=90) System.out.printf("me is a student with A letter-grade\n");Instructions-Java Assignment is to define a class named Address. The Address class will have three private instance variables: an int named street_number a String named street_name and a String named state. Write three constructors for the Address class: an empty constructor (no input parameters) that initializes the three instance variables with default values of your choice, a constructor that takes the street values as input but defaults the state to "Arizona", and a constructor that takes all three pieces of information as input Next create a driver class named Main.java. Put public static void main here and test out your class by creating three instances of Address, one using each of the constructors. You can choose the particular address values that are used. I recommend you make them up and do not use actual addresses. Run your code to make sure it works. Next add the following public methods to the Address class and test them from main as you go: Write getters and…
- 13) 0101011111 010101010101 1101010101 01100 Read the following class definition and answer afterword: class Student { public: Student() {}; Student(int ID, string name, string university){ m_university = university; cam Student:ID = ID; Student::name = name; }; string getUniName() {return m_university;} string getStudentName() {return m_name;} void print() { cout << "Student ID is: "<6 Java(b) Find all the errors in the C++ code below: class Point { private: int x, y: public: Point(int x = 0, int y = 0); int getX() const; // Getters void setX(int x); // Setters void setY(int y); }; Point:: Point(int x, int y) : x(x), y(y) { } // Using initializer list // Getters int Point::getX() const { return x; } int Point::getY) const { return y; } // Setters void Point::setX(int x) { this->x = x; } void Point::setY(int y) { this->y = y; } // Public Functions void print() const { cout « "(" « x« "," « y « ")" « endl; // Member function overloading '+' operator void Point::operator+(Point rhs) const { return Point(x + rhs.x, y + rhs.y); int main() { Point p1(1, 2), p2(4, 5); // Use overloaded operator Point p3 = p1 + p2; p1.print(); // (1,2) p2.print(); / (4,5) p3.print(); / i5,7) Point p5 = p1 + p2 + p3 + p4; p5.print (); // (15,21) cout<use python Call and Pass the values for the following class class std: def lis(**kwargs): for i, value in kwargs.items(): print("{0} {1}".format(i, value))3- Write a program to implement a class "student" with the following members. Name of the student. Marks of the student obtained in three subjects. Function to assign initial values. Function to compute total average. Function to display the student's name and the total marks. Write an appropriate main() function to demonstrate the functioning of the above.programmingind the error(s) in each of the following and explain how to correct it (them):a) Assume the following prototype is declared in class Time:void ~Time( int );Q4) Write the output of the following code segment public class CarStatic { public static void main (String [] args) ( for ( int i=0; i<3; i++ ) new Car.CarInfo (); class Car private static int numberofCars = 0; private int id; public Car () { id = numberofCars: ++numberofCars; public void CarInfo () { System.out.printf( "We have %d cars, Car ID is %d \n", numberofCars, id );)3. Consider the following two classes and write down the output of the following code: public class Test extends G{ void display() { String s = m1(); System.out.println("My name is "+ s); i - 7; j = j + i; } void show(){ System.out.println(" j value is - } public static void main(String args[]) { Test t - new Test(); System.out.println("s value is = t.display(); t.i = 9; System.out.println("i value in the object="+t.i); System.out.println("j value in the object="+t.j); t.show(); } abstract class G{ String s - "Exam"; int i = 10; int j - 5; String m1(){ s = "Java"; return s; abstract void display(); abstract void show( ); } " + j); + t.s);SEE MORE QUESTIONSRecommended textbooks for youDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSONC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag…Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill EducationDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSONC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag…Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education