Class and Object of Java - PowerPoint PPT Presentation

About This Presentation
Title:

Class and Object of Java

Description:

A class is a user defined blueprint or prototype from which objects are created.   It represents the set of properties or methods that are common to all objects of one type. In general, class declarations can include these components. – PowerPoint PPT presentation

Number of Views:19
Slides: 9
Provided by: priyakarthik123
Tags: java

less

Transcript and Presenter's Notes

Title: Class and Object of Java


1
Class and Object in Java
  • https//www.besanttechnologies.com/training-course
    s/java-training

2
Class
  • A class is a user defined blueprint or prototype
    from which objects are created.  
  • It represents the set of properties or methods
    that are common to all objects of one type. In
    general, class declarations can include these
    components.

3
Class
  • Modifiers  A class can be public or has default
    access.
  • Class name The name should begin with a initial
    letter (capitalized by convention).
  • Superclass(if any) The name of the classs
    parent (superclass), if any, preceded by the
    keyword extends.
  • Interfaces(if any) A comma-separated list of
    interfaces implemented by the class, if any,
    preceded by the keyword implements.
  • Body The class body surrounded by braces, .

4
Create a Class
  • Create a Class called MyClass and a Variable x
  • public class MyClass   int x  5

5
Object
  • It is a basic unit of Object Oriented
    Programming and represents the real life
    entities.  
  • A typical Java program creates many objects,
    which as you know, interact by invoking methods.

6
Object
  • State  It is represented by attributes of an
    object. It also reflects the properties of an
    object.
  • Behavior  It is represented by methods of an
    object. It also reflects the response of an
    object with other objects.
  • Identity  It gives a unique name to an object
    and enables one object to interact with other
    objects.

7
Create an Object
  • Create an Object called MyObj and print the
    value x
  • public class MyClass   int x  5public static 
    void main(String args)     MyClass myObj  new
     MyClass()    System.out.println(myObj.x) 

8
Class and Object Difference
  • A class is a blueprint or prototype that defines
    the variables and the methods (functions) common
    to all objects of a certain kind.
Write a Comment
User Comments (0)
About PowerShow.com