72. In a UML class diagram, the sharp (#) indicates: a. public access b. protect
ID: 3726615 • Letter: 7
Question
72. In a UML class diagram, the sharp (#) indicates: a. public access b. protected access within the definition of a constructor for a class, you can use (a) in the same class. a. constructor with appropriate parameters . public static variable c. private access d. package access 73, as a name b. reference variable Inheritance is an example of what type of relationship? a. is-a b. has-a Any new class you create from an existing class is called a(n)- a. base class b. superclass -74. d. this c. was-a d. had-a -75. c. derived class d. extended class there are three classes named Shape, Circle, and square. What is the most likely relationship between them? a. Square is a superclass, and Shape and Circle are subelasses of Square b. Shape is a superclass, and Circle and Square are subclasses of Shape. c. Shape, Circle, and Square are all sibling classes. d. These three classes cannot be related. 77. Parakeet based on the superclass Bird? what is the correct syntax for defining a new class a. class Parakeet isa Birdi ) b. class Bird defines Parakeet c. class Bird hasa Parakeet h d. class Parakeet extends Birdl 1 78. A subclass can directly access c. d. all members of a superclass none of the members of a superclass a. public members of a superclass private members of a superclass What type of inheritance does Java support? a. single inheritance b. double inheritance b. multiple inheritance Java does not support inheritance. 79. c. d. Ifclass a. Because of single inheritance, Dog can have no other subclasses b. Because of single inheritance, Retriever can extend no other class except Dog c. The relationship between these classes implies that Dog "is-a" Retriever. d· The relationship between these classes implies that Retriever "hase, Dog 80. Dog has a subclass Retriever, which ofthe following is true?Explanation / Answer
ANSWERS:
72.) b) protected access
- Indicates private
+ Indicates public
# Indicates protected
73.) a) constructor with another parameters:
public class Bok
{
private String title;
public Bok() //Constructor without parameters
{
//nothing specified!
}
public Book(String title)//constructor with parameters
{
//only title!
}
main(){
Bok b1=new Bok(); //Constructor without parameters invokes
Bok b2=new Bok("specs"); //Constructor with parameters invokes
}
}
74.) a.) Is a relationship
Derived class IS A Parent class type
Eg: SQUARE class IS A SHAPE CLASS
75.) c.) By definition it is called Derrived class or Child class if it derives from another class
76.) b.)Shape is a super class and Circle and Shape class are subclasses
Eg:
SHAPE CLASS:
public abstract class Shape {
public abstract double area();
public abstract double perimeter();
}
CIRCLE CLASS derived from SHAPE CLASS:
public class Circle extends Shape {
private final double radius;
final double pi = Math.PI;
public Circle() {
this(1);
}
public Circle(double radius) {
this.radius = radius;
}
public double area() {
return pi * Math.pow(radius, 2);
}
public double perimeter() {
return 2 * pi * radius;
}
}
SQUARE CLASS DERIVED from Shape:
public class square extends Shape {
private final double length; //sides
public square() {
this(1);
}
public square(double length) {
this.length = length;
}
@
public double area() {
return length * length;
}
public double perimeter() {
return 4*length;
}
}
77.) d) class Parakeet extends Bird{}
format to declare derived class:
class Derived extends Super{}
78.) a) public members of class
since public and protected members can be accessible by class,package,subclass.
private members can only accessed by other members of class
Since there is no protected ,the option is a)public members of class
79) a) Single inheritence
Java supports
1.Single Inheritence
2.Multilevel Inheritence
3.)Hierchial Inheritence
Java class doesn't support Multiple inheritence
80.) b) Because of single inheritence ,retriever can extend no other except dog.
Because this is the case of deriving class retriever from 2 base classes i.e multiple inheritence which is not available in Java.
81 .) 4 because 2 private vatriables in derived class
and 2 private variables in base class but derived can't access directly .Derived class can access private variables of base class by setters and getters in base class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.