Module 4 Code L
Write a short code snippet creating a class with three class variables and one method setting all three variables. The class is called Person and the variables should be name, birth, and address. You should supply a method called setAll() that will be used to set the values of the class variables.
// This is a JAVA program! I am a little confused any help would be great :)
import java.io.*;
class Person
{
String name,address;
int birth;
void setAll(String nm,String addr,int year)
{
name=nm;
address=addr;
birth=year;
}
public static void main(String []args)
{
// creating object
Person tom=new Person();
// call the set all function
tom.setAll("tom","xyz street",1998);
}
}
Get Answers For Free
Most questions answered within 1 hours.