What is Class in Java and Object Oriented Programming


Published on

Class and Object are two pillars of OOPS languages, see here http://javarevisited.blogspot.sg/2011/10/class-in-java-programming-general.html

or <a>Java67 Blog</a>

Published in: Education
1 Comment
  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

What is Class in Java and Object Oriented Programming

  1. 1. What is Class in Java Programminghttp://javarevisited.blogspot.com
  2. 2. What is Class in Java• Are you familiar with date types like int, long, float?• If Yes, than what is the limitation of these data types?• You got it right, they can only hold one type of data, i.e an int can only store integer values, a float can only store floating point values.
  3. 3. What is Class in Java• Then question comes, how do we represent user defined types e.g. Person which can have a String name, a long phone number and an int age• Class in Java is way to go.• Class in Java is used to create user defined types.
  4. 4. What is Class in Java• Benefit of user defined type is that it can combine and store multiple type and gives you power to create a user defined type for anything which exists in real world.• You can divide them into two category.• JDK or System classes and Application Classes
  5. 5. What is Class in Java• JDK Classes are those which comes along with JDK e.g. java.lang.String, java.lang.Thread• Application classes are those which you create in your Java program or application e.g. Person, Student etc• Class in Java is created using class keyword
  6. 6. What is Class in JavaHere is an example of user defined classclass Person{ int age; String name; long phone; public void int getAge(){ return age; }}
  7. 7. What is Class in Java• Except holding code for variables e.g. age, name and phone and methods e.g. getName(), class doesn’t do any thing.• Real magic starts when you create object of class.• For example every single person e.g. you, me and your friend are object of Person, they have different name, age and phone number but they are Person
  8. 8. What is Class in Java• Object are actual thing which is created from blueprint called class.• Just like every car including BMW, Merc and Audy has blueprint and follow specification, every object follows structure defined in class.• We learn more about object in Java in our next presentation.
  9. 9. What is Class in Java• In Summary you can say a Class in Java is – A user defined type – A way to combine multiple data types into one – A blueprint to create object – A structure to hold variables and methods together
  10. 10. Related Articles and Post• For more details on Class and Object in Java, See :• What is Class in Java programming language• What is Object in Java programming language• Website: http://javarevisited.blogspot.com /
  11. 11. LIKED IT?Tweet this presentation Share this on Facebook