Hi, I need help with this Java activity.
The requirements are:
1. Create a NetBeans project for this activity.
2. Create a new class with attributes name and address. Both data type will be String. Create a constructor and assign the parameters to the attributes.
3. Create a class with the main method and create an instance of the class that you created in Test Stem 1.
4. Create an instance of the string in your test class and assign a value.
5. Now create a String and assign a value with spaces in the beginning, end and middle.
6. In your test class with main method, instantiate a string buffer with the initial value of “hello”. Use the method setLength with parameter. Print the string representation of the StringBuffer using toString().
Thank you in advance.
import java.util.*;
class Person
{
private String name;
private String address;
// constructor
Person()
{
this.name = "";
this.address = "";
}
// constructor
// Create a constructor and assign the parameters to the attributes.
Person(String name, String address)
{
this.name = name;
this.address = address;
}
// override toString() method
public String toString()
{
return "Name : " + this.name + "\nAddress : " + this.address + "\n";
}
}
class Test
{
public static void main(String[] args)
{
// Create an instance of the string
String name = "Chandler";
// create a String and assign a value with spaces in the beginning, end and middle
String address = " New York ";
// create a new object of class Person
Person p = new Person(name, address);
System.out.println(p);
// instantiate a string buffer with the initial value of "hello"
StringBuffer s = new StringBuffer("Hello");
// set the length to 3 using setLength() method
s.setLength(3);
System.out.println(s.toString());
}
}
Sample Output

Hi, I need help with this Java activity. The requirements are: 1. Create a NetBeans project...
JAVA LANG PACKAGE Create a NetBeans project for this activity. 1: Create a new class with attributes name and address. Both data type will be String. Create a constructor and assign the parameters to the attributes. Now override the to String() method. 2: Create a class with the main method and create an instance of the class that you created 3: Create an instance of the string in your test class and assign a value. 4: Now create an String...
Java Project Create a NetBeans project for this activity. Test Stem / Question Choices 1: Create a new class with attributes name and address. Both data type will be String. Create a constructor and assign the parameters to the attributes. Now override the toString() method. Is this possible? A: Yes. B: No. C: In some cases where the attributes are only strings. D: Yes, as long as you explicitly extends Object class. 2: Create a class with the main method...
Start a new project in NetBeans that defines a class Person with the following: Instance variables firstName (type String), middleInitial (type char) and lastName (type String) (1) A no-parameter constructor with a call to the this constructor; and (2) a constructor with String, char, String parameters (assign the parameters directly to the instance variables in this constructor--see info regarding the elimination of set methods below) Accessor (get) methods for all three instance variables (no set methods are required which makes...
signature 1. Create a new NetBeans Java project. The name of the project has to be the first part of the name you write on the test sheet. The name of the package has to be testo You can chose a name for the Main class. (2p) 2. Create a new class named Address in the test Two package. This class has the following attributes: city: String-the name of the city zip: int - the ZIP code of the city...
Deliverable
A zipped NetBeans project with 2 classes
app
ZipCode
Address
Classes
Suggestion:
Use Netbeans to copy your last lab (Lab 03) to a new
project called Lab04.
Close Lab03.
Work on the new Lab04 project then.
The Address Class
Attributes
int number
String name
String type
ZipCode zip
String state
Constructors
one constructor with no input parameters
since it doesn't receive any input values, you need to use the
default values below:
number - 0
name - "N/A"
type...
Create a NetBeans project called "Question 1". Then create a public class inside question1 package called Author according to the following information (Make sure to check the UML diagram) Author -name:String -email:String -gender:char +Author(name:String, email:String, gender:char) +getName():String +getEmail):String +setEmail (email:String):void +getGender():char +tostring ):String . Three private instance variables: name (String), email (String), and gender (char of either 'm' or 'f'): One constructor to initialize the name, email and gender with the given values . Getters and setters: get Name (), getEmail() and getGender (). There are no setters for name and...
MasterMind in Java
Activity
MasterMind project
Create a new Java Application project named MasterMind
allowing Netbeans IDE to create the main class called
MasterMind.java
MasterMind class
Method main() should:
Call static method System.out.println() and result in
displaying “Welcome to MasterMind!”
Call static method JOptionPane.showMessageDialog(arg1, arg2)
and result in displaying a message dialog displaying “Let’s Play
MasterMind!”
Instantiate an instance of class Game()
constants
Create package
Constants class
Create class Constants
Create constants by declaring them as “public static final”:
public...
Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the concept of a college course, assuming that a course has following attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the behavior of the class and its methods. The outline of the class is given as follows: public class Course...
Book: - title: String - price: double +Book() +Book(String, double) +getTitle(): String +setTitle(String): void +getPrice(): double +setPrice(double): void +toString(): String The class has two attributes, title and price, and get/set methods for the two attributes. The first constructor doesn’t have a parameter. It assigns “” to title and 0.0 to price; The second constructor uses passed-in parameters to initialize the two attributes. The toString() method returns values for the two attributes. Notation: - means private, and + means public. 1....
Homework assignment need help
3. Create the constructor, area and toString method for the following class (2 point) public class. Square private double a; Ll...area of square is a*a In the test class replace commented lines with your code. public class. Test Square public static void main (String[] args) // Create an instance of Square I. Print the area using area method // Print the instance using toString method