Identify the constructor in the firstclassoops class

Assignment Help JAVA Programming
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.

//

}

}

Reference no: EM131181816

Questions Cloud

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.

Reviews

Write a Review

 

JAVA Programming Questions & Answers

  String as input and returns the reverse of that string

Write a method that takes a String as input and returns the reverse of that String. Then write a second method that uses the first method to test whether or not an input String is a palindrome.

  Programming languages for example pascal

Some programming languages for example Pascal have used the semi colon to seperate statements while java uses it to terminate the statements. which of them in your opinion is most natural and least likely to result in syntax errors? support your a..

  Bullpart 1 several types of point of interests poi such as

bullpart 1 several types of point of interests poi such as - 1 petrol station 2 taxi stand 3 atm 4 hospital and 5

  Write a generic linked list tree

Write a generic linked list tree and a generic linked list binary search tree class that inherits from your generic linked tree class

  Write a java program that will play connect four

Write a java program that will play connect four - Must be a simple program no applets, jframes.

  Invoice application that validates the data

Code to the Invoice application that validates the data the user enters. That includes exception handling code as well as specific data validation methods

  Describe the relationship between a gui component and events

Describe the relationship between a GUI component and events? What is the programmer's responsibility when developing a GUI, event-driven program

  Littlest rebel starring shirley temple

Compare the novel Little Women by Louisa May Alcott and the film The Littlest Rebel starring Shirley Temple. How do these two intertwine or influence each other?

  Implement a java program that generates the receipt

Create a Receipt class that could be used by an automobile parts store. Items to include as data members are receipt number date of purchase, customer number, customer name and address, customer phone number, item number, description, unit price, ..

  Write applet which reads five numbers-draw equivalent stars

Write the applet which reads five numbers (each between 1 and 30). For each number read, your program must design line containing that number of adjacent asterisks.

  Determine values of the side of triangle

Enter 3 integers and determine if these 3 values make up the sides of a triangle. If any side is

  Calculates the average test scores

You are given a list of students' names and their test scores. Design an algorithm that does the following: a. Calculates the average test scores.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd