Question
QUESTION 12 Match the following code snippets with the concept they exemplify. - A. B. C. D. E. F. G. H. I. J. generic class
QUESTION 12
-
Match the following code snippets with the concept they exemplify.
- A. B. C. D. E. F. G. H. I. J. generic class
- A. B. C. D. E. F. G. H. I. J. instantiation
- A. B. C. D. E. F. G. H. I. J. accessor method
- A. B. C. D. E. F. G. H. I. J. constructor
- A. B. C. D. E. F. G. H. I. J. subclass
- A. B. C. D. E. F. G. H. I. J. polymorphism
- A. B. C. D. E. F. G. H. I. J. model
- A. B. C. D. E. F. G. H. I. J. view
- A. B. C. D. E. F. G. H. I. J. controller
- A. B. C. D. E. F. G. H. I. J. delegate
A. public class MakeShapes { public static void main(String[] args) { Rectangle rect = new Rectangle(6.0, 8.0); Circle circ = new Circle(6.0, 8.0); System.out.println(Rectangle: + getData(rect)); System.out.println(Circle: + getData(circ)); } public static String getData(Shape s) { return s.getData(); } }
B. function calculate(){ var r = parseFloat(document.getElementById('radius').value); // Check for nonnumeric data if(isNaN(r)){ document.getElementById('data').innerHTML = "Please enter numbers only"; return; } // Check for negative data if(r
C. Square s1 = new Square();
D. Circles Program Calculates Area and Perimeter of Circles
Enter the radius:
E. public Cylinder(double rad, double h) { myCircle = new Circle(rad); this.height = Circle.checkData(h); }
F. public class Triangle extends Shape { private double s1, s2, s3; public setSides(double side1, double side2, double side3) { if ((side1 + side2 > side3) && (side1 + side3 > side2) && ( side2 + side3 > side1) { s1 = side1; s2 = side2; s3 = side3; } else { s1 = 1; s2 = 1; s3 = 1; } public String getSides() { return Side 1: + s1 + Side 2: + s2 + Side 3: + s3; } public double getArea() { double s = (s1 + s2 + s3); return Math.sqrt(s * (s-s1) * (s-s2) * (s-s3)); } public double getPerimeter() { return s1 + s2 + s3; } public String getData() { return getSides() + Area: + getArea() + Perimeter: + getPerimeter(); } }
G. public class Cyclinder { private Circle circle; private double height; . . . . }
H. public class Square { private sideLength; public double getSideLength() { return sideLength; } public void setSideLength(double s) { sideLength = s; } public double getArea() { return s * s; } public void getPerimeter() { return s * 4; } }
I. function Circle(r){ this.radius = r; this.getArea = getA; this.getPerimeter = getP; this.getData = getD; } function getA(){ return this.radius * this.radius * Math.PI; } function getP(){ return 2 * this.radius * Math.PI; } function getD(){ return 'Area: ' + this.getArea() + '
Perimeter: ' + this.getPerimeter(); }J. public String getName() { //assumes that the class this method belongs to // contains a data member named name of type String return name; }
2 points
QUESTION 13
-
Given the UML class diagram seen in the accompanying figure, what is/are the classs data member(s)?
Rectangle
length and width
getArea and getPerimeter
Unknown
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started