100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

COSC 121 Exam Questions and Answers Latest Update Graded A+

Rating
-
Sold
-
Pages
25
Grade
A+
Uploaded on
23-10-2024
Written in
2024/2025

COSC 121 Exam Questions and Answers Latest Update Graded A+ If a subclass provides a specific implementation of a method that is already provided by its parent class, it is known as Method Overloading - Answers False Correct the following code public class D { private double mass; D() { this(10.); Sln("No-arg constructor"); } D(double mass){ Sln("Constructor"); mass = mass; } public double getMass() { return mass; } public void setMass(double mass) { D.mass = mass; } } - Answers public class D { private double mass; D() { this(10.); Sln("No-arg constructor"); } D(double mass){ Sln("Constructor"); = mass; } public double getMass() { return mass; } public void setMass(double mass) { = mass; } } What is the output of the following statements: Truck mycar = new Truck(); Sln(mycar); if we have the following classes: public class Car { public void m1() { Sln("car 1"); } public void m2() { Sln("car 2"); } public String toString() { return "general car"; } } public class Truck extends Car { public void m1() { Sln("truck 1"); } } - Answers general car Match each code fragment to the correct type of relationship class Truck{ Engine engine; Truck(){ Engine engine = new Engine(); (); } } - Answers Composition class Truck{ Engine engine; Truck(Engine engine){ e = engine; (); }

Show more Read less
Institution
COSC 121
Course
COSC 121










Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
COSC 121
Course
COSC 121

Document information

Uploaded on
October 23, 2024
Number of pages
25
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

COSC 121 Exam Questions and Answers Latest Update Graded A+

If a subclass provides a specific implementation of a method that is already provided by its parent class,
it is known as Method Overloading - Answers False

Correct the following code



public class D {

private double mass;

D() {

this(10.);

System.out.println("No-arg constructor");

}

D(double mass){

System.out.println("Constructor");

mass = mass;

}

public double getMass() {

return mass;

}

public void setMass(double mass) {

D.mass = mass;

}

} - Answers public class D {

private double mass;

D() {

this(10.);

System.out.println("No-arg constructor");

,}

D(double mass){

System.out.println("Constructor");

this.mass = mass;

}

public double getMass() {

return mass;

}

public void setMass(double mass) {

this.mass = mass;

}

}

What is the output of the following statements:



Truck mycar = new Truck();

System.out.println(mycar);

if we have the following classes:

public class Car {

public void m1() {

System.out.println("car 1");

}



public void m2() {

System.out.println("car 2");

}

, public String toString() {

return "general car";

}

}

public class Truck extends Car {

public void m1() {

System.out.println("truck 1");

}

} - Answers general car

Match each code fragment to the correct type of relationship



class Truck{

Engine engine;

Truck(){

Engine engine = new Engine();

engine.start();

}

} - Answers Composition

class Truck{

Engine engine;

Truck(Engine engine){

this.engine = engine;

engine.start();

}

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
TutorJosh Chamberlain College Of Nursing
View profile
Follow You need to be logged in order to follow users or courses
Sold
342
Member since
1 year
Number of followers
16
Documents
28567
Last sold
1 day ago
Tutor Joshua

Here You will find all Documents and Package Deals Offered By Tutor Joshua.

3.6

53 reviews

5
18
4
14
3
12
2
0
1
9

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions