#4.1 Java Tutorial | Class and Object

Published: 19 January 2018
on channel: Telusko
310,681
4.6k

Check out our courses:

Spring Framework in 8 Full Day Course Live: https://go.telusko.com/SPRING8DAYS2
Coupon: TELUSKO10 (10% Discount)

Complete Java Developer Course Batch-3: https://go.telusko.com/completebatch3
Coupon: TELUSKO10 (10% Discount)

Master Java Spring Development : https://go.telusko.com/masterjava
Coupon: TELUSKO20 (20% Discount)

Udemy Courses:

Spring: https://go.telusko.com/udemyteluskosp...
Java:- https://go.telusko.com/udemyteluskojava
Java Spring:- https://go.telusko.com/Udemyjavaspring
Java For Programmers:- https://go.telusko.com/javaProgrammers
Python : https://go.telusko.com/udemyteluskopy...
Git : https://go.telusko.com/udemyteluskogit
Docker : https://go.telusko.com/udemyteluskodo...

For More Queries WhatsApp or Call on : +919008963671

website : https://courses.telusko.com/

In this lecture we are discussing:
1) What is class and object?
2) Understanding class and object with real world example?
3) What are things inside a class?
a) example with their syntax
4) what is difference between reference variable and object ?

#1
What is class ?
As for definition you can say that class is blueprint of logical entity or real world entity.

e.g with some terms:
An entity can be of two types:
Tangible Entity: Tangible Entities are those entities which exist in the real world physically.
Example: Person, car, etc.
Intangible Entity: Intangible Entities are those entities which exist only logically and have no physical existence.
Example: Bank Account, etc.

What is object?
Object are either real world entity or logical entity or we can say instance of class.

#2
Understanding class and object with real world entity.
e.g
Suppose a civil engineers get a project to create a multiple same building in a locality.
Step 1: for that first they create a blueprint of building.
step 2: using this blueprint they can create multiple buildings.
step 3: but might be colour and use of this building depend on the user.

blueprint of building --- class
real concrete building --- object
colour and design --- variable
use of building --- method

now we are get better look of class and object.

#3
What are things inside a class?
:- class has two things mainly
a) variables --- know something (from building example we got colour and design of building)
b) methods --- does something (from building example we got idea use of building depend on user)

:- now come to programming world example of variable and methods
Syntax for creating class
class class_name{
//instance variable
//method
}

e.g
class Calculator{
int num1; //num1 is instance variable
int num2; //num2 is instance variable
int result; //result is instance variable

public void add(int num1, int num2) // add is method
{
result=num1+num2;
System.out.println(result);
}

public void sub(int num1, int num2) //sub is method
{
result=num1-num2;
System.out.println(result);
}
}

Note:
i) In upcoming video we are talking about void and public, but here you can only understand what is methods and variable.
ii) instance variable is a variable which is declared inside the class but outside the method .
iii) their is local variable which are created inside the methods but we will talk about this in upcoming videos.

#4
Difference between reference variable and object creation?

class Main{
public static void main(String []args){
Calculator obj; //here obj is reference variable not a object
obj=new Calculator(); // now new Calculator() create object of Calculator types
//reference variable is a variable which is used to store the address of object and object created in heap
}
}

Instagram :   / navinreddyofficial  
Linkedin :   / navinreddy20  
Discord :   / discord  

More Learning :

Java - https://bit.ly/3xleOA2
Python :- https://bit.ly/3H0DYHx
Django :- https://bit.ly/3awMaD8
Spring Boot :- https://bit.ly/3aucCgB
Spring Framework :- https://bit.ly/3GRfxwe

Servlet & JSP :- https://bit.ly/3mh5CGz
Hibernate Tutorial :- https://bit.ly/3NWAKah
Rest API | Web Service Tutorial :- https://bit.ly/38RJCiy

Git :- https://bit.ly/3NUHB3V
JavaScript :- https://bit.ly/3mkcFys
Kotlin :- https://bit.ly/3GR2DOG


On this page of the site you can watch the video online #4.1 Java Tutorial | Class and Object with a duration of hours minute second in good quality, which was uploaded by the user Telusko 19 January 2018, share the link with friends and acquaintances, this video has already been watched 310,681 times on youtube and it was liked by 4.6 thousand viewers. Enjoy your viewing!