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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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