Java -OOP concepts( Classes and Objects)


What is the java class?
Class is a blueprint of the object or set of instructions for creating a specific type of object. Class is like an object constructor.

Ex:-
            public class UserName{
                   int id;
                   String name;
                   int age;

                   public void run(){
                          System.out.println("I'm Running");
                   }
            }




What is the java object?
The object is an instance of the class.

Ex:-

            public class Main{
                    public static void main(String args[]){
                            UserName user = new UserName();
                    }
            }

2 Comments

Post a Comment
Previous Post Next Post