OOP concept clearings from some MOOC courses

Code:

Student.java

 

class Student{


    //variable declaration
    int id;
    String name;
    String gender;


    //method deinitions
    boolean updateProfile(String newName){
        name=newName;
        return true;
    }



}

 

StudentTest.java
class StudentTest{


    public static void main(String[] args){


//Creating a new student object
Student s = new Student();


//setting student state


s.id =1000;
s.name="Zaki";
s.gender="male";



//3. Update your profile with correct name
s.updateProfile("John");


    }



}

 

 

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *