# Questions 1. Briefly explain how polymorphism makes a statically...

## Question

Questions
1. Briefly explain how polymorphism makes a statically typed language ”a little bit dynamically typed.”
2. In the space provided, describe the characteristics of an abstract or pure virtual method.
3. Unlike C++, Java does not experience the deadly diamond of death in multiple- inheritance. How does Java avoid this problem?
4. Using the following code fragment for a vector with three dimensions, complete the required methods in each space provided:
#include<iostream>
#include<cmath>
using namespace std;

class Vec3 {
private:
double values[3];

public:
Vec3( double v0, double v1, double v2 ){
values[0] = v0;   values[1] = v1;   values[2] = v2;
}
}
(a) Define the copy constructor:
(b) Create a two parameter mutator method:
(c) Overload the * operator such that when the Vec3 is multiplied by a float it returns a scaled Vec3 object (e.g. Vec3(1,2,3) * 2 == Vec3(2,4,6)):

(d) Create a normalize method which modifies the vector’s current values to unit length. That is, the normalize function adjusts the existing values in the Vec3 object such that the length from the origin at 0,0,0 to the point defined in Vec3 is one unit. Hint: Pythagoras

(e) The three-dimensional cross product of two vectors produces a new vector or- thogonal to the two original vectors. Produce the code necessary to create a class method which computes a cross product between its saved values and another Vec3 vectors. This method shall take a single parameter and return a Vec3 object with the orthogonal values. Given two vectors a and b, the scalar components for the cross product (s = s0i + s1j + s2k = aXb) follow:
s0 = a1b2 − a2b1
s1 = a2b0 − a0b2
s3 = a0b1 − a1b0

5. Identify one disadvantage with the object-oriented principle of inheritance. That is, how might it complicate or hider a design?
6. What are some of the downsides of the computer programming concept of reflection?

## Solution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <cstdlib>
#include<iostream>
#include<cmath>
using namespace std;

class Vec3 {
private:
double values[3];

public:
Vec3(double v0, double v1, double v2) {
values[0] = v0;
values[1] = v1;
values[2] = v2;
}

/**
* Define the copy constructor:
*/
Vec3(const Vec3 & v) {
values[0] = v.values[0];
values[1] = v.values[1];
values[2] = v.values[2];
}

/**
* Create a two parameter mutator method:
*/

void setVect(int start, double values[]) {
this->values[0] = values[start];
this->values[1] = values[start + 1];
this->values[2] = values[start + 2];
}...

By purchasing this solution you'll be able to access the following files:
Solution.cpp.

# 50% discount

Hours
Minutes
Seconds
\$27.00 \$13.50
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.