Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Lecture 8


Published on

Notes on core java
sub- OOPS

Published in: Education, Technology
  • Be the first to comment

Lecture 8

  1. 1. Core Java Debasish Pratihari Introduction to OOPs:  Object-oriented programming provides a superior way of organizing programming projects  It encourages a high degree of modularity in programming, making large projects easier to implement  It provides powerful techniques like inheritance and polymorphism to help organize and reuse code Features of OOPs:  Abstraction  Encapsulation  Inheritance  Polymorphism Procedural vs. Object-Oriented Programming :  The unit in procedural programming is function, and unit in object-oriented programming is class  Procedural programming concentrates on creating functions, while object-oriented programming starts from isolating the classes, and then look for the methods inside them.  Procedural programming separates the data of the program from the operations that manipulate the data, while object-oriented programming focus on both of them Lecture/core/oops1/08 Page #1 feel the Technology…
  2. 2. Core Java Debasish Pratihari Introduction to Class :  In object-oriented programming, a class is a programming language construct that is used as a blueprint or prototype to create objects.  it is an abstraction of a concept within a computer program.  It encapsulates state through data placeholders called member variables or fields; it encapsulates behavior through reusable code called methods or behavior.  A class has a constructor for creating objects Member of a class           Instance variable Class variable Local variable Instance method Class methods Constructors Initialization codec(Static code blocks) Finalize method Class (inner class) interface or non-static The Java Language Specification allows the followings:  Declare a class inside another class or inside an interface.  Declare an interface inside another interface or inside a class.  Declare a class inside a method.  Nest classes and interfaces declarations arbitrarily deep. Lecture/core/oops1/08 Page #2 feel the Technology…
  3. 3. Core Java Debasish Pratihari Declaring a class: Syntax : <class modifier> class <identifier>{ // Body here } Example: public class Laskhya{ //Body here } Access Modifiers:  Keywords that help to set the visibility, accessibility, or certain properties of a class, its member variables, and methods. Class Modifiers For Outer class     public abstract final strictfp For inner class  private  public  protected  abstract  final  strictfp Note: A class can’t be both final and abstract Field Declaration :  a type name followed by the field name, and optionally an initialization clause  field declarations can be preceded by different modifiers     Lecture/core/oops1/08 private public protected transient    volatile static final Page #3 Note: A field can’t be both final and volatile feel the Technology…
  4. 4. Core Java Debasish Pratihari Access control modifiers:  private: private members are accessible only in the class itself.  package: package members are accessible in classes in the same package and the class itself.  protected: protected members are accessible in classes in the same package, in subclasses of the class, and in the class itself.  public: public members are accessible anywhere the class is accessible. static modifier : 25%  only one copy of the static field exists, shared by all objects of this class  can be accessed directly in the class itself  access from outside the class must be preceded by the class name or via an object belonging to the class  from outside the class, non-static fields must be accessed through an object reference Final modifier :  once initialized, the value cannot be changed  often be used to define named constants  static final fields must be initialized when the class is initialized  non-static final fields must be initialized when an object of the class is constructed Lecture/core/oops1/08 Page #4 feel the Technology…