In: Computer Science
object oriented programming java
Create a Student class that have two data members id (assign to your ID) and name (assign to your name). Create the object of the Student class by new keyword and printing the objects value. You may name your object as Student1. The output should be like this:
20170500
Asma Zubaida
Create a file named Student.java and add below code in it.
public class Student {
//id data member
String id = "20170500";
//name data member
String name = "Asma Zubaida";
}
Create a file named Main.java and add below code in it
public class Main
{
public static void main(String[] args) {
//creates object of Student class
Student Student1 = new Student();
//prints object's value
System.out.println(Student1.id);
System.out.println(Student1.name);
}
}
Please refer below screenshot for indentation and output of the code.
Student.java
Main.java