What does this print in java? public class Main { private double myGPA; private int myCredits; public
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
public class Main { private double myGPA; private int myCredits; public void increaseCredits(int amount) myCredits myCredits + amount; } public void setCredits(int credits) { myCredits credits; [P] public int getCredits() { return myCredits; } public static void main(String[] args) { Main S new Main(); s.setCredits (6); s.increaseCredits (12); System.out.println(s.getCredits()); } public class Main { private double myGPA; private int myCredits; public void increaseCredits(int amount) myCredits myCredits + amount; } public void setCredits(int credits) { myCredits credits; [P] public int getCredits() { return myCredits; } public static void main(String[] args) { Main S new Main(); s.setCredits (6); s.increaseCredits (12); System.out.println(s.getCredits()); }
Expert Answer:
Answer rating: 100% (QA)
public class Main instance variables of the Main class private double myGPA priva... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
How do you simplify the max method in the following, using the conditional operator? 1: /** Return the max of two numbers */ 2: public static int max ( int num1, int num2 ) { 3: int result; 4: 5: if...
-
Aircraft.java public class Aircraft implements Comparable { int numEconomySeats; int numFirstClassSeats; String model; public Aircraft(int seats, String model) { this.numEconomySeats = seats;...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
At year-end 2010, 28,879 million represents: A. the funded status of the plan. B. the defined benefit obligation. C. the fair value of the plans assets. Kensington plc, a hypothetical company based...
-
A control rod is attached to a crank at A and cords are attached at B and C. For the given force in the rod, determine the range of values of the tension in the cord at C knowing that the cords must...
-
Today is April 12, 2024, and you, CPA, are a senior accountant with Kenney & Niu LLP. You just got out of a meeting with a new client, Alan Morneau, who has approached your firm for some tax advice....
-
Discuss the importance of communication in managing a technology change. What roadblocks might an organization face if it fails to create a good communication plan?
-
Suresh Co. expects its five departments to yield the following income for next year. Recompute and prepare the departmental income statements (including a combined total column) for the company under...
-
A partial listing of accounts for Z Ltd. is shown below: Account Amount Accounts payable $36,000 Interest revenue $2,400 Accumulated depreciation - equipment $4,500 Salaries payable $2,300 Salaries...
-
Mack Banta, a nonexempt account representative, worked extra hours this week as a call operator. A number of operators were out for the week and Banta was asked to pick up some of their hours. Can...
-
Solve! (x+ 2y) dy = y dx non-linear in y
-
Calculate nominal GDP in 2022 and 2023. An economy produces only apples and oranges. The base year is 2022, and the table gives the quantities produced and the prices. Quantities Apples Oranges...
-
Discovery and Warner Media Merge The merger of Discovery and Warner Media creates one of the largest U.S. media bisinesses. The deal still needs to receive FTC approval. a. What is the difference...
-
In 2018 Brazils real GDP is growing at 1.7 percent a year and its population is growing at 0.7 percent a year. If these growth rates continue, in what year will Brazils real GDP per person be twice...
-
The United States produces corn in abundance whereas Japan faces a shortage of corn. a. If the United States starts to export corn in large quantities to Japan, what do you predict will be the effect...
-
Why might an increase in the gas tax to finance transportation infrastructure be a political equilibrium? New Jerseys gas tax, which is rising from 30.9 to 40.2 cents per gallon, is needed to support...
-
3. A ball is thrown up from the top of the tower. For parts a-c, state whether the ball's acceleration is larger than g, equal to g, zero, or -g (assume up is positive and that g = 9.80 m/s). a. Just...
-
As water moves through the hydrologic cycle, water quality changes are common because of natural phenomena or anthropogenic pollution. Using Figure 11.1, describe how water-quality changes occur...
-
Write a loop that will create a new string that is the reverse of a given string.
-
For all of the following words, if you move the first letter to the end of the word, and then spell the result backwards, you will get the original word: banana dresser grammar potato revive uneven...
-
Write a program that will read a line of text as input and then display the line with the first word moved to the end of the line. For example, a possible sample interaction with the user might be...
-
Write a simple loop that lets you exercise the cache. By changing the number of statements in the loop body, you can vary the cache hit rate of the loop as it executes. If your microprocessor fetches...
-
Why do most computer systems use memory-mapped I/O?
-
Draw a timing diagram for a burst write operation that writes four locations.
Study smarter with the SolutionInn App