Classes and objects in java

Опубликовано: 29 Июнь 2020
на канале: 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();
}
}


На этой странице сайта вы можете посмотреть видео онлайн Classes and objects in java длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Techlearners By Neeraj Saxena 29 Июнь 2020, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 350 раз и оно понравилось 8 зрителям. Приятного просмотра!