Reference no: EM131181816
Java and OOPs Assignment
Assignment:
To use a class, call the constructor. Below are two Java classes. The name of the first isFirstClassOOPS. It defines variables, constructors, and methods. The second class isClassClient. In ClassClient, the constructor for FirstClassOOPS is called. The constructor initializes the variable name to "John Smith" and age to 62. Then a method inFirstClassOOPS is used to print out the results below.
My name is John Smith.
My age is 62.
Part I:
Modify the code to make sure the print out is as follows.
My name is John Smith.
My age is 62.
Part II:
Identify the following in the FirstClassOOPS class.
Constructor(s)
Mutator Methods (Set methods)
Acessor Methods (Get methods)
Name of methods that returns values
Name the methods that do not return any values
List the methods that have parameters.
FirstClassOOPS
public class FirstClassOOPS {
// Declare Variables
private String sName;
private int sage;
//Create default constructor
public FirstClassOOPS()
{
sName="None";
sage = 18;
}
//Create a constructor
public FirstClassOOPS(String name, int age)
{
//initialize variables
sName = name;
sage = age;
}
//Mutator Method = Method that changes the name
public void setName(String name)
{
sName = name;
}
// Mutator Method = Method that changes the age
public void setAge(int age)
{
sage = age;
}
//Getter Method = Method that returns the value of Name
public String getName()
{
return sName;
}
//Getter Method = Method that returns the value of age
public int getAge()
{
return sage;
}
//To String Method = returns the name and age
public String toString()
{
String message = "My name is "+sName+".\nMy age is "+sage+".";
return message;
}
}
ClassClient below.
public class ClassClient {
public static void main(String[] args)
{
//Create a FirstClassOOPS variable with name = John Smith and age = 62
FirstClassOOPS g = new FirstClassOOPS();
String outPutString = g.toString();
System.out.println(outPutString);
// The output should be
// My name is John Smith.
// My age is 62.
//
}
}
Current real gdp is less than the potential gdp
: Suppose the current real GDP is less than the potential GDP. Explain the ways fiscal and monetary policy can increase real GDP. Be sure to focus on the specific tools, and use the concepts of aggregate demand (fiscal policy) and money supply (mone..
|
What is meant by the internet of things
: What is meant by the "Internet of Things" - what business value does it create? Explain your answer. Make sure to reference your sources
|
Why did chavez decide to nationalize cargill
: Why did Chavez decide to nationalize Cargill? Do you think he was justified?If you were the executive of Cargill, what would you do?
|
List them out in decimal notation
: Using the addresses listed below - Give the following information and Subnet ID - along with all subnets available for use - List them out in decimal notation
|
Identify the constructor in the firstclassoops class
: To use a class, call the constructor. Below are two Java classes. The name of the first isFirstClassOOPS. It defines variables, constructors, and methods. Identify the Constructor in the FirstClassOOPS class.
|
What is the importance of alignment of marketing strategy
: What is the importance of the alignment of the marketing strategy with the corporate strategy? Is it possible to have one global marketing strategy such as a standardized marketing mix, or must the marketing strategy be adapted for each individual ma..
|
How much in taxes will the local government collect
: The town then imposes a tax of $0.20 per bottle. Illustrate this on your graph. What is the new equilibrium price and quantity for bottles of soda?
|
Public relations campaign and explain in detail
: Describe the mix of media you would use to implement your public relations campaign and explain in detail your objectives for each media form. Explain in detail how you can take advantage of community relations to generate positive publicity for yo..
|
Create a client class in java to call the sorting class
: Create a client class to call the sorting Class. Pass the array of scores to the Sorting class. Sort the array from smallest to largest and printout the sorted array.
|