No video

#1 class and object in java | Java for Beginners

  Рет қаралды 7,934

SG Tutorial

SG Tutorial

Күн бұрын

#1 Java for Beginners | class and object
About this video:
This tutorial will explain concept of class and object with real life Point of view and with programming point of view too..
Timestamp:
0:40 What is a class?
1:34 What is an object?
3:43 How to create a class?
4:16 Syntax to Create a class
7:11 How to create an object?
7:25 Syntax to create an object
9:13 Example
Links:
To learn about basics of Java click here 👇
• Java Basics
Java Methods :
• #2 Method in Java | Ja...
Java variable declaration and initialization:
• #4 Variable Declaratio...
Java Constructor :
• #5 Java Constructor | ...
NOTES :
1.What is a class?
2.What is an object?
3.How to create a class?
4.How to create an object?
1.What is a class?
Class is a prototype from which objects can be created.
Class can also be defined as
The collection of objects because,you can create multiple objects using single class.
2.What is an object?
Object is instance of a class..
This means, object is a result that we get from a class..
And each object has it's fields /characteristics and actions / functions
For example,
Mobile Phone,
Mobile Phone is also an object..
And each mobile phone has
It's fields like,
colour, height, screenSize.
And actions like,
calling,ringing,sendData, receivedData etc.Remember one thing about class and object..
When we execute/ run the program then first program will load into memory and then execute
That means, first program will occupy some space into memory and then execute
Similarly,
In java,
During the execution of program,
first program load into memory this means will occupy some space into memory and then execute but class won't occupies any space into memory during the execution of program because
Class is logical entity.
So Class is work as file in that we have to put our logic
hence class will just be saved as a file on hard drive.
But object occupies memory during the execution of program because object is physical entity because
each object has it's actions.
This means each object can perform certain task.
Such as, Mobile Phones
Mobile Phone is also one of an object and it also has it's actions like,
Calling,ringing,send data, received data etc.
So basically,
In java, object is considered as a physical entity and class is considered as a logical entity.
3.How to create a class?
To create a class you can use following Syntax
AccessModifier ClassKeyword ClassName
{
// Class Members;
}
Access-modifier:
access - modifier controls the access level/ scope of a class.
In java, there are four type of access modifier.It's public,private,protected,and default but you can use only two access modifier for a class.It's public and default
If you declared class with
modifier public then class is accessible or visible to all classes in a program and if a class has no modifier then it's considered as a default and it is visible only within its own package and won't visible to other packages.
NOTE:Package is a group of related classes.
class-keyword:
Class keyword is used to create a class.
Class keyword is predefined keyword / reserved keyword.
Class keyword should be in lower-case otherwise compiler will raise an error because, Java is
a case-sensitive language.
Class-Name:
Class name should always start with upper case letter.
Class-Body:
Class body surrounded by curly braces.
Class body contain class members and class members are fields and actions so fields are called as Variables and actions are called as Methods.
For example:
public class Test
{
//declaring variables
int var1;
int var2;
//declaring methods
public void display (){}
}
In this example,
public is access modifier and Test is class name.
var1 and var2 are variables (fields) and display() is method (actions)
4.How to create an object?
To create an object you can use following syntax
Syntax:
Class_Name object_name = new_keyword Class_Name();
new-keyword:
"new" keyword is used to create an object
It is a predefined keyword that java provide us to create an object and
during the creation of an object compiler immediately allocate memory to an object and hence "new" keyword is also used to allocate memory to an object..
"new" keyword followed by class name and parantheses it represents the constructor of the class.
Constructor is a special method that has same name as that of a class.
Constructor is used to give initial value to an object.
That means when object creation take place then compiler immediately allocate memory to an object and give initial value(default values) to an object.
NOTE:Default values might be 0 or null.
For example:
You can create an object as follows,
Test obj = new Test();
here,
Test is class name,obj is object name and Test() is constructor.
_________End___________
Thank you for watching 🙏
#javaclassandobject #classandobjectinjava #sgtutorial #javatutorial #javatutorialforbegginers #java #classinjava #objectinjava #class #object

Пікірлер: 26
@nagrajnateekar8211
@nagrajnateekar8211 2 жыл бұрын
First time i liked to java tutorial...why people are unaware of this channel don't know
@abubakarsadiqahmad8234
@abubakarsadiqahmad8234 7 ай бұрын
Very satisfying, thanks alot.
@sgtutorial22
@sgtutorial22 6 ай бұрын
Thank you so much..keep learning..!
@jayyadav1298
@jayyadav1298 2 жыл бұрын
Thanks mam, for teaching in very simple and easy language with examples.
@sgtutorial22
@sgtutorial22 2 жыл бұрын
Thank you so much.. keep learning..
@arunmaharajae7375
@arunmaharajae7375 2 жыл бұрын
Super man Iam also Assistant professor it is helpful for me for taking class
@sgtutorial22
@sgtutorial22 2 жыл бұрын
Thanks a lot for your feedback...!
@meghatiwari5225
@meghatiwari5225 6 ай бұрын
Hello, please add more videos , string , array, exceptional handling, few programs . Thanks
@sgtutorial22
@sgtutorial22 6 ай бұрын
Yes sure, will upload soon.. happy learning!
@nsshankey
@nsshankey 2 жыл бұрын
Excellent explanation ❤️❤️❤️👍👍
@sgtutorial22
@sgtutorial22 2 жыл бұрын
Thank you so much..
@malarvizhi1842
@malarvizhi1842 2 жыл бұрын
brilliant teaching
@sgtutorial22
@sgtutorial22 2 жыл бұрын
Thank you so much.. keep learning...
@jyotibarge5864
@jyotibarge5864 2 жыл бұрын
Thanks mam.plz make video on java for for beginners with tutorial.You explain very well 😍😍
@sgtutorial22
@sgtutorial22 2 жыл бұрын
Yes, will do.. Thank you so much..!!
@shubhamsonawane6205
@shubhamsonawane6205 2 жыл бұрын
Oh wow mam thank u so much .. Real time examples helps me a lot … Ur voice is also so soothing N animations also helps to understand concept thank u so much Pls share Array,string,singleton,Oops concept pls mam . Pls share video about tht
@sgtutorial22
@sgtutorial22 2 жыл бұрын
Yes , will share... Thanks a lot for your kind feedback...🙏
@dharmendrd.s.l.t6474
@dharmendrd.s.l.t6474 2 жыл бұрын
Hi techar
@shaliniyadav450
@shaliniyadav450 2 жыл бұрын
do u hAVE any c and c++ tutorial channel
@sgtutorial22
@sgtutorial22 2 жыл бұрын
No,not yet...but thanks for suggetion...
@badagyan5002
@badagyan5002 2 жыл бұрын
I want to see notes
@sgtutorial22
@sgtutorial22 2 жыл бұрын
Notes are mentioned in description of each video tutorial.. you can see it..thank you...!!
@nagrajnateekar8211
@nagrajnateekar8211 2 жыл бұрын
Why dont u conti mam java tutorials?
@sgtutorial22
@sgtutorial22 2 жыл бұрын
Yes,it will continue..be ready to learn..
@sanjayverma-cp2yx
@sanjayverma-cp2yx 2 жыл бұрын
Pls speak like "in Java" not "in a Java" many times you have said "in a Java"
@sgtutorial22
@sgtutorial22 2 жыл бұрын
Thanks a lot for your feedback...
#2 Method in Java | Java for Beginners | Java Method
16:19
SG Tutorial
Рет қаралды 4,9 М.
If Barbie came to life! 💝
00:37
Meow-some! Reacts
Рет қаралды 67 МЛН
Running With Bigger And Bigger Feastables
00:17
MrBeast
Рет қаралды 129 МЛН
Kind Waiter's Gesture to Homeless Boy #shorts
00:32
I migliori trucchetti di Fabiosa
Рет қаралды 11 МЛН
WORLD'S SHORTEST WOMAN
00:58
Stokes Twins
Рет қаралды 192 МЛН
Java Classes & Objects
11:36
Keep On Coding
Рет қаралды 315 М.
9. Java Memory Management and Garbage Collection in Depth
48:48
Concept && Coding - by Shrayansh
Рет қаралды 68 М.
Inheritance in JavaScript - Prototypal Inheritance tutorial
20:06
Learn Java in One Video - 15-minute Crash Course
14:54
Coding with John
Рет қаралды 689 М.
Java Multithreading | Purpose and  Uses of Java Multithreading
13:29
If Barbie came to life! 💝
00:37
Meow-some! Reacts
Рет қаралды 67 МЛН