Class Definition Ch 04-1
import java.text.DecimalFormat;
public class Student
{
private String name;
private String major;
private double gpa;
private int hours;
public Student(String newName, String newMajor, double
newGPA, int newHours)
{
name = newName;
major = newMajor;
gpa = newGPA;
hours = newHours;
}
public String toString()
{
// xxxx needs to be replaced
DecimalFormat df = new DecimalFormat("xxxx") ; return name + "\n" + major + "\n" + df.format(gpa)
+ "\n" + hours
}
}
-Refer to Class Definition Ch 04-1: Another method that might be desired is one that updates the student's number of credit hours. This method will receive a number of credit hours and add these to the student's current hours. Which of the following methods would accomplish this?
A) public int updateHours()
{ return hours; }
B) public void updateHours()
{ hours++; }
C) public updateHours(int moreHours)
{ hours += moreHours; }
D) public void updateHours(int moreHours)
{ hours += moreHours; }
E) getClassRank(sq) ;public int updateHours(int moreHours)
{ return hours + moreHours; }
Correct Answer:
Verified
Q42: Class Definition Ch04-2
The following is from a
Q43: Explain why it would be a poor
Q44: Class Definition Ch 04-4
public class Box
{
double length;
double
Q45: Class Definition Ch 04-4
public class Box
{
double length;
double
Q46: When reasoning about a car, we use
Q48: Class Definition Ch 04-3
Consider a class called
Q49: Class Definition Ch 04-4
public class Box
{
double length;
double
Q50: Class Definition Ch04-2
The following is from a
Q51: Class Definition Ch 04-4
public class Box
{
double length;
double
Q52: Assume method0 calls method1 and method2, method1
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents