Comment down
for any queries
Please give a thumbs up if you are satisfied with the
answer
ANSWERS)
1) string name;
2)set the name;
3) second option
4)REFREGRATOR ONE
5)item's scope
6)coping and pasted code.....
7)stack frame
8) if other statements are changed then there is 90% chance we have to change the calling
9)return;
10)(int x, int y)
11)sumVal=sumVal +readingVal;
Comment down
for any queries
Please give a thumbs up if you are satisfied with the
answer
whats the answer When defining a class which has the field name of type String. How...
Give answer according to fill in the blanks. 1.Define a class called Fraction . This class is used to represent a ratio of two integers.Include mutator methods that allow the user to set the numerator and the denominator. Also include a method that returns the value of numerator divided by denominator as a double . Include an additional method that outputs the value of the fraction reduced to lowest terms (e.g., instead of outputting 20/60, the method should output 1/3)....
What output is produced by the following program? public class MysteryNums public static void main(String[] args) - int x = 12; int y = x - 3; 3, sentence (y, x + y); . public static void sentence (int numi, int num2) { 4: System.out.println(num1 + " + num2);
Java Questions When creating a for loop, which statement will correctly initialize more than one variable? a. for a=1, b=2 c. for(a=1, b=2) b. for(a=1; b=2) d. for(a = 1&& b = 2) A method employee() is returning a double value. Which of the following is the correct way of defining this method? public double employee() c. public int employee() public double employee(int t) d. public void employee() The ____ statement is useful when you need to test a...
I was wanting to know how would I call my add class through my if statement. Here is my class: import java.util.Scanner; public class Main { public static void main(String[] args) { int num1 = 0; int num2 = 0; int answer = 0; int userInput = 0; Scanner sc = new Scanner(System.in); System.out.println("Hello, this is a program where you can choose...
4. Command pattern //class Stock public class Stock { private String name; private double price; public Product(String name, double price) { this.name = name; this.price = price; } public void buy(int quantity){ System.out.println(“BOUGHT: “ + quantity + “x “ + this); } public void sell(int quantity){ System.out.println(“SOLD: “ + quantity + “x “ + this); } public String toString() { return “Product [name=” + name + “, price=” + price + “]”; } } a. Create two command classes that...
This is my playlist class: class Playlist{ private String name; private int numberOfRecordings = 0; private int durationInSeconds = 0; private int MAX_PLAYLIST_SIZE; Recording recordingslist[]; Playlist(){ name = "Unknown"; MAX_PLAYLIST_SIZE = 5; recordingslist = new Recording[MAX_PLAYLIST_SIZE]; durationInSeconds = 0; } Playlist(String name, int size){ this.name = name; this.MAX_PLAYLIST_SIZE = size; recordingslist = new Recording[MAX_PLAYLIST_SIZE]; ...
public class Pet { //Declaring instance variables private String name; private String species; private String parent; private String birthday; //Zero argumented constructor public Pet() { } //Parameterized constructor public Pet(String name, String species, String parent, String birthday) { this.name = name; this.species = species; this.parent = parent; this.birthday = birthday; } // getters and setters public String getName() { return name; ...
Read through the code of the class Player, noting it has two instance variables, name and rank, which are of type String and three further instance variables won, drew and lost which are of type int. There is also an attribute of the class, points, which does not have a corresponding instance variable. Also note the constructor and methods of the class and what they do. TournamentAdmin class code: public class RankAdmin { /** * Constructor for objects of class...
Rational will be our parent class that I included to this post, Implement a sub-class MixedRational. This class should Implement not limited to: 1) a Constructor with a mathematically proper whole, numerator and denominator values as parameters. 2) You will override the: toString, add, subtract, multiply, and divide methods. You may need to implement some additional methods, enabling utilization of methods from rational. I have included a MixedRational class with the method headers that I used to meet these expectations....
The FoodItem.java file defines a class called FoodItem that contains instance variables for name (String) and calories (int), along with get/set methods for both. Implement the methods in the Meal class found in Meal.java public class FoodItem{ private String name; private int calories; public FoodItem(String iName, int iCals){ name = iName; calories = iCals; } public void setName(String newName){ name = newName; } public void setCalories(int newCals){ calories = newCals; } public int getCalories(){ return calories;...