RUVIDEO
Поделитесь видео 🙏

Class and Object in Java | How to Create Class in Java | Java Programming | RiseShineKG2PG смотреть онлайн

This Video is all about how to create classes and objects in java programming language.
it explaines you following concepts related cerating calsses and objects in java.
1. How to create a class
2. How to ad Attribute to class
3. How to add methods to class
4. How to create object of calss
5. How to acess and use the attribute and method within the class using dot opertator.

Detailted explination about class and object in Java:
A class in Java is declared using the class keyword. A source code file in Java
can contain exactly one public class, and the name of the file must match the
name of the public class with a .java extension.
The fields and methods of a class appear within the curly brackets of the
class declaration. The following code shows a simple class with no fields or
methods declared yet.
public class Employee
{
}
Adding Fields to a Class
The attributes of an object become fields in the corresponding class. A field within a class consists of the following:
Access specifier, which can be public, private, or protected; or the access specifier can be omitted, giving the field the default access.
Data type.
Name, which is any valid identifier that is followed by a semicolon.

After adding attribute class will be as below

public class Employee
{
public String name; //First and last name
public String address; //Mailing address
public int number; //Employee number
public double salary; //Employee’s annual salary
}

Adding Methods to a Class
Behaviors of an object become methods in the corresponding class. A method within a class typically consists of the following:
1. Access specifier
2. Return value
3. Name, which can be any valid identifier
4. List of parameters, which appears within parentheses
5. Definition or implementation of the method

The following class code demonstrates the way by adding a method to the Employee
class.
public class Employee
{
public String name;
public String address;
public int number;
public double salary; // Annual Salary
}
public double computePay() //compute monthly salary
{
return salary/12;
}
}

Now how to create an object of this class
The following statements declare an Employee reference and use the new keyword to assign the reference to a new Employee object.

Employee e;
e = new Employee();

The reference e is pointing to the Employee object in memory. The new operator allocates memory for the object and then “zeroes” the memory so that none of the object’s fields will contain garbage.

This statement creates two separate elements in memory: the reference e and
the Employee object. The reference e is not an object. The object itself does not
have a variable name, and the only way you can access and use the object is to
use a reference to the object.

Accessing Fields and Methods:
When you instantiate an object using the new keyword, memory is allocated
for each of the fields and methods in the class. You need a reference to the
object to access these fields and methods using the dot operator.
For example, the following statements declare an Employee object and
change the name field of the object:
Employee e = new Employee();
e.name = “ ABC XYZ”;
The operation e.name is the way to access the name field of the Employee
an object that e refers to.
Similarly, the following statement uses the dot operator
to invoke the method of this particular Employee object:

e.computePay( );

You will now write a second class that instantiates and uses Employee objects.
Using your text editor, type in the following EmployeeDemo class.
public class EmployeeDemo
{
public static void main(String [] args)
{
Employee e1, e2;
e1 = new Employee();
e2 = new Employee();
e1.name = “ XYZ ABC”;
e1.address = “123 Pune, India”;
e1.number = 101;
e1.salary = 10000.00;
System.out.println(e1.computePay());

e2.name = “PQR ABC”;
e2.address = “321 Delhi India”;
e2.number = 202;
e2.salary = 100000.00;
System.out.println(e2.name + “ “ + e2.SSN);
System.out.println(e2.computePay());
e2.mailCheck();
}
}

To watch more videos on
Java Programming | Java Full Course
https://www.youtube.com/playlist?list=PL5neT6krvZKYXMvBhSwACOVu4iDlErp8-

Object-Oriented Programming using C++:
https://www.youtube.com/playlist?list=PL5neT6krvZKY1CYr2I1acDhv5fSeLp7D6

Database Management System:
https://www.youtube.com/playlist?list=PL5neT6krvZKahsbZsMNba5Cg-woFsghmj

Python Programming Full Course:
https://www.youtube.com/playlist?list=PL5neT6krvZKbADR3yeFArwseHHH0sLTPI

Web Development using Angular Full Course:
https://www.youtube.com/playlist?list=PL5neT6krvZKaX5tQ4c0Zfuby_fQd5oHNV

Software Design and modeling using UML / OOAD:
https://www.youtube.com/playlist?list=PL5neT6krvZKY2aq1pMF6V9ycr-DTu7arp

To watch more videos on the preparation of the Competitive Exam:
https://www.youtube.com/playlist?list=PL5neT6krvZKY7yALg426NFbYiBbfv2Fvp

Channel URL www.youtube.com/riseshinekg2pg

#javaprogramming #RiseandShineEducations #J2SE #class

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Class and Object in Java | How to Create Class in Java | Java Programming | RiseShineKG2PG» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.