Identify the problems in the following code:
1 public class Circle {
2 private double radius;
3
4 public Circle (double radius) {
5 radius = radius;
6 }
7
8 public double getRadius() {
9 return radius;
10 }
11
12 public double getArea() {
13 return radius * radius * Math.PI;
14 }
15 }
16
17 class B extends Circle {
18 private double length;
19
20 B(double radius, double length) {
21 Circle(radius);
27 length = length;
23 }
24
25 @Override
26 public double getArea() {
27 return getArea() * length;
28 }
29 }
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
Mechanics of Materials (10th Edition)
Modern Database Management
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Starting Out With Visual Basic (8th Edition)
- java code, pls use more // commentsarrow_forwardProblem C • -3: method consonants() had more than one loop • -3: method initials () had more than one loop • -3: at least one method used nested loopsarrow_forwardclass 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++; y1++;z++;}}; class B {protected: int x,y; public: B(a,b):x(a+1),y(b+2) { for(i=0; i<5;i++) x+=2; y+=1;}}; class D:public B, virtual public A { private: int a,b; public: D(k,m,n): a(k+n), B(k,m),b(n+2),A(k,m,n) { a=a+1;b=b+1;}}); int main() {D ob(4,2,5);} what the values of x1,y1 and zarrow_forward
- Consider the following class definition: (8) class base { public: void setXYZ(int a, int b, int c) ; voidsetX ( int a ) ; int getX ()const{returnx; } void setY ( int b ); intgetY()const{returny; } int mystryNum () {return ( x &*#x00A0;y - z &*#x00A0;z) ;} void print () const; base () } base(int a, int b, int c); protected: void setz ( int c) { z= c; } void secret(); int z= 0; private: int x= 0; int y = 0; }; a. Which member functions of the class base are protected? b. Which member functions of the class base are inline? c. Write the statements that derive the class myclass from class base as a public inheritance. d. Determine which members of class base are private, protected, and public in class myclass.arrow_forwardThe following class declaration has errors. Locate as many as you can. class Box {private:double width;double length;double height; public:Box(double w, l, h){ width = w; length = l; height = h; } // Overloaded prefix ++ operator void operator++(){ ++width; ++length; } // Overloaded postfix ++ operator void operator++(){width++; length++; }... Other member functions follow ...};arrow_forward#pyhton programing topic: Introduction to Method and Designing class Method overloading & Constructor overloading ------------------ please find the attached imagearrow_forward
- 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, barrow_forwardSoftware Requirements: • Latest version of NetBeans IDE • Java Development Kit (JDK) 8 Procedure: 1. our progras from rhFactor non-static and private. Remove the constructor with two (2) parameters. 2o upply uncapsutation Make bloodType and 2. The names of the public setter and getter methods should be: • setBloodType() • setRhFactor() getBlood Type() getRhFactor() 3. Use the setter methods to accept user input. 4. Display the values by calling the getter methods. Sample Output: Enter blood type of patient: Enter the Rhesus factor (+ or -): O+ is added to the blood bank. Enter blood type of patient: B Enter the Rhesus factor (+ or -): B- is added to the blood bank.arrow_forwardInstruction: Given the definition of methods and fields available to the Fraction class below, extend it to a Generic Mixed Number class that can perform the different arithmetic operations. Requirement: use Fraction class methods in performing the different mixed number operations. class Fraction{ } private int num, denom; public Fraction(int num, int denom) { /* code elided */ } public Fraction add(Fraction another){ /* code elided */ } public Fraction subtract (Fraction another){ /* code elided */ } public Fraction multiply (Fraction another){ /* code elided */ } public Fraction divide (Fraction another){ /* code elided */ } public int getNumerator() { /* code elided */ } public int getDenominator() { /* code elided */ } A mixed number can be created with the following data combination. 1. 1 number - treated as the whole part, the numerator defaults to 0 and denominator defaults to 1 2. 2 numbers - treated as numerator and denominator, hence whole defaults to 0 3. 3 numbers -…arrow_forward
- 3. Look at the following code. Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8 Line 9 Line 10 Line 11 Line 12 Line 13 Line 14 public class ClassA { } = public class ClassB extends ClassA { } public ClassA() { public int method1(int a){} public int method2(int b){} Line 15 Line 16 Line 17 } public ClassB(+ public int method2(double c){ public class classC extends ClassA { public ClassC(+ public int method1(int b){} public int method2(double c){ Assume the classes ClassA, ClassB, ClassC are defined similar to the above. If the reference variables var1, var2, var3, and var4 are declared as: ClassA var1 = new ClassA(); ClassC var3 = new ClassC(); ClassB var2 = new ClassB(): ClassB var4 = new ClassB(): Which of the following lines is indicative of polymorphism in Java? A. var3 = var1; B. var2 = var3; C. var1 = var3; D. var4 var1;arrow_forwardQUESTION 15 public class numClass { private int a; private static int y = 10; public numClass(int newX) {a=newx; } public void set(int newx) { a=newx; y+=a; } public void setY(int newy) { y=newY; } public static int getY() { return y; } }// end of class public class output { public static void main(String[] args) { numClass one = new numClass(10); numClass two = new numClass (2); try{ one. sety(30); two.set(4); if(one.getY()==30) throw new Exception ("30"); one.setY(40); } catch (Exception e) { two.sety (50); } System.out.println(two.getY()); }// end of main } // end of classarrow_forwardanswer the ff in essay formarrow_forward
- Database 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:PEARSON
- C 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