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

  Round the average score to one decimal

The number format in one decimal place to make this to round the average score to one decimal in this program.

  Implement a validation plan to get a valid input

You need to implement a validation plan to get a valid input from the user for product code. An input value is considered invalid if: it is not a number at all

  Implement a fish-lake simulation

Implement a Fish/Lake simulation similar to the previous assignment. You will then make adjustments to accommodate class hierarchies and make use of inheritance as well as a JAVA interface.

  Use the correct syntax of a common programming

This assignment requires you to write a Java program to carry out a series of operations as specified below. The appendix at the back of the assignment specification provides an example of the output required from the final program.The tasks required..

  Web engineering principles

web application development, Web Engineering methodology, UML-based Web Engineering (UWE), models to the expansion of web applications, Object Oriented Web Solutions (OOWS),Web Modeling Language (WebML) methodology, Object-Oriented Hypermedia Design..

  Compute performance matrix

Write a program in JAVA that will take inputs from a file and compute performance matrix similar to the following output into an output file.

  Marketing necessary for practice-hospital to successful

Why is marketing necessary for a practice or hospital to be successful? What considerations should be taken into account when marketing health care services or products? (Hint think about all the medication ads you seen on tv or in magazines)

  Write a program that that displays a dialog box

Write a program that that displays a dialog box show a message and a randomly chosen color. This random color is to be used as the background color of a JFrame window which should appear after "OK" is selected

  Elements from a html document

Function test Count List Elements should simply retrieve an array of all list elements on the page and assert that their total count is 3.

  Define a class to model linear equation of variables x and y

Define a class to model a linear equation of variables x and y in slope intercept form. A skeleton for this file is provided in the project pack.

  Print the contents of the array

Prepare a second loop that prints the contents of the array

  Describe how a semaphore can be used to act like a lock.

The loop should execute until a "shutdown" flag is set to true on the runnable object executing in the thread.

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