• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 27 pages
Exam (elaborations)

Code HS Unit 4 Study Guide Questions Graded A+ 2025/2026

Document preview thumbnail
Preview 3 out of 27 pages

Code HS Unit 4 Study Guide Questions Graded A+ 2025/2026 4.1.7 Calling A Method - RectangleT: public class RectangleTester extends ConsoleProgram { public void run() { /* * Rectangle is the name of the class. Every Rectangle * has a width and a height. But the specific instances * have their own dimensions. */ Rectangle r1 = new Rectangle(7, 14); Sln(Height()); Sln(Width()); Sln(Area()); } } R: public class Rectangle { private int width; private int height; public Rectangle(int rectWidth, int rectHeight) { width = rectWidth; height = rectHeight; } public int getArea()

Content preview

Code HS Unit 4 Study Guide Questions Graded A+
2025/2026
4.1.7 Calling A Method - RectangleTester.java:
public class RectangleTester extends ConsoleProgram
{
public void run()
{
/*
* Rectangle is the name of the class. Every Rectangle
* has a width and a height. But the specific instances
* have their own dimensions.
*/
Rectangle r1 = new Rectangle(7, 14);
System.out.println(r1.getHeight());
System.out.println(r1.getWidth());
System.out.println(r1.getArea());
}
}

Rectangle.java:
public class Rectangle
{
private int width;
private int height;

public Rectangle(int rectWidth, int rectHeight)
{
width = rectWidth;
height = rectHeight;
}

public int getArea()
{
return width * height;
}

public int getHeight()
{
return height;
}

public int getWidth()
{
return width;

,}

public String toString()
{
return "Rectangle with width: " + width + " and height: " + height;
}
}

4.1.8 Using the Point Class - PointTester.java:
public class PointTester extends ConsoleProgram
{
public void run()
{
Point p = new Point(10, 5);
System.out.println(p);
p.move(3, 4);

System.out.println(p);

// Make a new point here at position (2, 4)
Point a = new Point(2, 4);

// Then print it out
System.out.println(a);
}
}

Point.java:
public class Point
{
private int x;
private int y;

public Point(int xCoord, int yCoord)
{
x = xCoord;
y = yCoord;
}

public void move(int dx, int dy)
{
x += dx;
y += dy;
}

public String toString()

, {
return x + ", " + y;
}
}

4.1.9 Using the Student Class - StudentTester.java:
public class StudentTester extends ConsoleProgram
{
public void run()
{
Student alan = new Student("Alan", "Turing", 11);
Student ada = new Student("Ada", "Lovelace", 12);
Student luke = new Student("Luke", "Drelick", 12);
// Add an entry for yourself here!

System.out.println(alan);
System.out.println(ada);
// Print out your student object
System.out.println(luke);
}
}

Student.java:
public class Student
{
private String firstName;
private String lastName;
private int gradeLevel;

public Student(String fName, String lName, int grade)
{
firstName = fName;
lastName = lName;
gradeLevel = grade;
}

public String toString()
{
return firstName + " " + lastName + " is in grade: " + gradeLevel;
}
}

4.2.5 Text Messages - Messages.java:
public class Messages extends ConsoleProgram
{
public void run()

Document information

Uploaded on
January 30, 2025
Number of pages
27
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$10.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

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.
PLANTER
3.5
(43)
Sold
299
Followers
11
Items
37014
Last sold
1 week ago



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

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions