Classes and objects in java

Veröffentlicht am: 29 Juni 2020
auf dem Kanal: Techlearners By Neeraj Saxena
350
8

#techlearners #java #class
Class is the basic unit of object orientation in java. class is a blueprint of an object in java
Class can be termed as composite or user defined data type

class contains
1 set of attributes - class variables/instance variables
2 set of methods - class methods/instance methods
3 constructor
4 destructor

Example
public class Student
{
public int rollnumber;
public String name;

public void input()
{
// method body here
}
public void display()
{
// method body here
}
}

class is a blueprint, blueprint can not be used but
from blueprint object is created, this object is used

When a class is created no memory allocation is allocated

Memory is allocated when object of a class is created

Object implement the functionality defined by class

Object is the executable copy of class hence called instance

Object creation
Student s1=new Student();

public class Student
{
public int rollnumber;
public String name;

public void input()
{
// method body here
}
public void display()
{
// method body here
}
public static void main(String args[])
{
Student s1=new Student();
s1.input();
s1.display();
Student s2=new Student();
s2.input();
s2.display();
}
}


Auf dieser Seite können Sie das Online-Video Classes and objects in java mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Techlearners By Neeraj Saxena 29 Juni 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 350 Mal angesehen und es wurde von 8 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!