object-and-class-in-java

 


  Master Skill



Explain  object and the class in java 
java is an object oriented programming language " everything in java associated with the class and object along with its attribute and mention and methods as such as drive & brack

  For example 
in real life , a car is attributes the car has attributes such as weight and color, and method as such drive and brack

" A class is like an object constructer or blue print for creating object

Create a class

// To create a class , used the class keyword

create a class named "main "  with the variable  x;
         public class main
           {
              int x=5;
         }

 create a object 

 in java an object is created form a class we a have already create the class named main so now we can use this to create object
To create a main  object of (main)

For example 
create an object called " my obj " and print the value

public void main 
   {

            int x =s:
            public starict void main (string args[])
      {
           main my obj=new main();
           system.out.println(myobj.c);
     
      }

 }

multiple object
You can create multiple object og an object

For example 
 create two object of main

public staric void main (string arg[])


{

              main.mainobj1=new main()
}

Comments

people like this

Disable-Knox-Tool-download

Explain-Java-Array-masterskill

Operators In java-masterskill