Saturday, 28 April 2018

BHARTI JAVA


*Introduction of Java
                                                                    Java was developed by a term of computer propositional under the guidance of James gosling and his team at the sum Microsystems of USA in 1991 he wanted to gave a suitable name initially he called “OAK “after scanning OAK tree from their window but after sun weeks he was discussing another name and he was slipping java coffee so one of them suggested the name Java.
                                              Java is simple and purely object oriented and general purpose programming language with powerful feature which can be used to developed a verity of application from simple web animation to high an business application that program and hold devices micro web application across platform application e. t. c.
                               Java is strongly type language this specification clearly distinguished between the compile time error and run time. It is both compiled as well as interpreted and comes in the form of java byte code is run one interpreted to executed a program this byte code is the actual power of java. It is popular and dominating over other programming language.
*Features of Java   :
                                  There are following features of java.
(1)             Compiled and Interpreted.
(2)             Platform – Independent.
(3)         Object Oriented.
(4)             Easy to learn.
(5)             Robust and Secure.
(6)             Multithreaded and Interactive.
(7)             Dynamic and extensible.
(8)             Familiar, simple and small.
(9)             Distributed.
(10)     High performance.
                
·    Object oriented programming
The object oriented programming is that program which is organized around  the data being protect  open rather than the operation perform the basic idea behind object oriented programming is combining both data and its function . That operates on the data in to a single unit is called object an object is anything that distinguished really exist in the word and it can be 1 form other.
The main components of OOPS are following.
(1)Class
(2)Object
(3)Encapsulation
(4)Abstraction
(5)Inheritance
(6)Polymorphism
(1) Class:-
               A class is a blue prints are prototype that defines the variables and the methods common to all object of certain kind.
                                                                             The programmers define the object from it and behavior by defining a class in other words .A class is a collection of object of similar type and method.
(2) Object:-
                 An object is software that is bundle of variables and related method we can represent real world object by using software object.
(3) Encapsulation:-
                             The wrapping of update and function in to single unit is called encapsulation this is most important features of OOPS.
(4) Abstraction:-
                              Abstraction refers to the act of representing essential features without including the back grouping details to the distinguished object or function from other object or function.
(5) Inheritance:-
                               Inheritance is ability to derived new class from existing class.
A derived class is known as sub class which inheritance the instance variable
And method of super class, class or object. Class it can add sum new instance class or variable and method.
(6) Polymorphism:-
                                 After class and inheritance polymorphism is the next essential features of object oriented programming language it allows are name to be used for several related but different purpose we used to spacefiy. A general class of action method overloading is one kind of polymorphism.
· Application of OOPS:-
                                    There are following application of OOP.
(1)   Object Oriented Database
(2)   Embedded System
(3)   Simulation And Modeling
(4)   Natural Network
(5)   Decision Support System
(6)   Office automation System
(7)   AI And Expert System
(8)   Internet Solution
(9)   Real-time Systems
· Features ‘of OOPS:-
There are following features of OOPS.

(1)   It emphasis is on data rather than procedure.
(2)   Programs are modularized into entities called objects.
(3)   Data structure methods characterize the objects of the problem.
(4)   It is easier to maintain program.
(5)   It employs bottom-up approach in program design.
(6)   There is no scope of accidental modification of data in this language.
· Benefits of OOPS:-
                           (1) Ease in division of job.
                           (2) Reduce complexity.
                           (3) Provide extensibility.
                           (4) Eliminate redundancy.
                           (5) Saves development time and increases productivity.
                           (6) Allows building secure programs.
                           (7) Allows designing simpler interfaces.
*Class and object base program
  Class Class_name
{
Data type1 variable1;

………………………….
………………………….
Data type n variable
Data type method name ()

{
Body of method
}
}
  Class class _ name
{
Public static void main ()
{
Class name     object name
Object name = new class name ();


Or
Calling function
}
}


(1)            Write a program to calculate the sum of two numbers using class and object.
Class sum
{
     int a, b, c;
    void add()
   {
      a=10;
      b=20;
      c=a+ b+ c;
       System.Out.Println(“Sum of two numbers:”+c);
        }
}
      Class Display
{
    public static void main(string args[])
     {
       Sum S;
S =new Sum();
S.add();
}
}


(1)              public class Babul
{
    public static void main(String args[])
    {
        long p =1;
        int n;
        double q;
        System.out.println(" 2 to power -n n 2 to power n");
        for(n = 0; n < 10; n++)
        {
            if (n == 0)
            p = 1;
            else
                p = p * 2;
            q = 1.01 /(double)p;
            System.out.println( " "  + q + " " + n + " " +p );
        }
           
    }
   
}

(2)               
              
public class Cube
{
    public static void main(String args[])
    {
        int a,cu;
        a=3;
        cu=3*3*3;
        System.out.println("cube of number:"+cu);
               
    }
   
}


·   Variable
             A variable is a basic unit of storage  in java program it represent memory allocation in which value can be store java has meanly three types of variable.
(1)   Instance variable
(2)   Class variable
(3)   Local variable
(1)Instance variable:
                            That variable which is use to define the attribute of a particular object is called instance variable.
(2)Class variable:
                      Instance variable is also known as class variable it accepts they are variable. Apply to all the instance of a class.
(3)Local variable :
                         That variable which is used in declare inside method or function is called local variable. For ex:- for index countries an looks temporarily variable are to hold values that be need only inside the method definition itself.
Syntax:-
Data type1- - - - - - - - - variable 1
Data type2 - - - - - - - - - variable 2
-      - - - - - - - - - - - - - - -  - - - - - - -
-        - - - - - - - - - - - - - - - - - - - - - -
Data type n - - - - - - - - variable n

Class and Object
    Class
         A class is a group of values with a set of operation to manipulate this value it is use to define a new data type ones a new data type is define variable of this data type can be create in program for solving problem.
Object
                 Object is the primary object oriented programming language the support any data including the under derived data type simply object means reads words it is main properties of opps it is created meanly two stapes.
Method overloading :
All the method of similar kinds in the glass and its name is same but all the methods will have different prototype is called method overloading this methods may have different return types.
Method overriding:
In program writing more than two method in super or sub classes such as the method and same signature is called method overriding.
Static method
Static method is a method which does not declare and variable the instance variable of a class. It is declared by using the static keyword. It is called using class name (.) method name because static method cannot act own instance variable that is the JVM1 execute the static method and only it create the object the object called the static method.
Inheritance
When create new class from existence class so that the new classes will acre all the feature of the existence classes is called inheritance it is language property specific to the object oriented paradigm. It is use in invert from of accurse shaving by longing we take the implementation of any even task and built a new class base done implementation. It is used for extending the existing property of a class.
For ex: Inheritance in nature parents producing the children inheritance the quality of the parent.
Abstract class:
An abstract class is a class that can contain sub abstract class is a class that contains 0 or more abstract method since abstract class contains in complete method. It is implemented by its child class that is abstract class can be used only as parent class.
Interface:
                   An interface is a specification of method prototype all the methods’ of a interface are public and abstract is use to provide method to be implemented by classes and interface it has to define all the method given in that interface a class can implemented more than one interface.
   
        

(5)public class Rani
{
    public static void main(String args[])
    {
        System.out.println("Screen Display ;");
        for(int i=1; i<=9;i++)
        {
            for(int j=1; j<=i; j++)
            {
                System.out.print(" ");
                System.out.print(i);
            }
            System.out.print("\n");
        }
        System.out.println("Screen Display Done");
               
           
   }     
   
}
(6)
public class Pavan
{
    public static void main(String args[])
    {
        int a = 1,b=5,c=3,cube,sum;
        System.out.println(" a ="+a);
        System.out.println(" b ="+b);
        System.out.println(" c ="+c);
        System.out.println(" a*a*a =" +(a*a*a));
        System.out.println(" b*b*b =" +(b*b*b));
        System.out.println(" c*c*c =" +(c*c*c));
        System.out.println(" a+b+c =" +(a+b+c));
       
    }
       
   
}
String:
A string represent and array of characters when the last character will be null ‘%’ represent the end of the string but this is not valid in java
                                                                    In java a string is an object of string class it is not a character arrays also but strings are given a different treatment.  Java soft people have created a class separately with the name string in java. Lan package with all necessary method to work with string. 

·      Vector:
That class which can be used to create a Generic dynamic array is called vector it can hold object of any type and any number so vector is a class it contain in the java. 

(7)   Write a program in java to calculate the simple       interest.
public class Sonu
{
    public static void main(String args[])
    {
        int p,r,t,si;
        p=200;
                  r=10;
           t=2;
        si=(p*r*t)/100;
        System.out.println("simple interest:"+si);
    }
} 
(8)     Write a program in java to print the working of days.
        
public class Workingdays
{
    enum Days
    {
        Sunday,
        Monday,
        Tuesday,
        Wednesday,
        Thursday,
        Friday,
        Saturday
    }
    public static void main(String args[])
    {
        for  (Days d:  Days.values())
        {
             Weekend(d);
        }
    }
    private static void weekend(Days d)
    {
        if(d.equals(Days.Sunday))
 System.out.println("value “ = + d + “ is a Holiday ");
else     
System.out.println(“value =”+d+ “ is a working day”);    
                                                           
       
        }
       
       
       
    }
    
   
}    


   
}

No comments:

Post a Comment