Showing posts with label Introduction. Show all posts
Showing posts with label Introduction. Show all posts

Tuesday, 11 June 2013

OOP Principles

1. Encapsulation:

Encapsulation is the mechanism that binds together code and the data it manipulates ,and keeps both safe from outside interface and misuse..
the Data members and the member functions that are binded together in a block act as a fixed block and no data member or member function outside the class can access the members of class unless it has the rights to access them..
class Encap
{
void sum()
{
int a,b,c;
a=10;
b=20;
c=a+b;
System.out.print("Sum is"+c);
}
}
Only the objects of this class can access these functions and data members.


2. Inheritance:

Inheritance means one class inherits the features of some other class. The member functions are not again written in to the derived class but the member functions of base class are directly copied into the derived class. The objects of derived class can access the member functions of base class.
Base class is also known as parent class and the derived class is also known as child class.
Following are two main types of inheritance.


3. Polymorphism

Polymorphism allows one interface to be used for a general class of actions. Polymorphism in simple means"ability to take more than one form" , means you can use different functions with same name to perform different task, the functions may need to have different number of arguments, on the basis of number of arguments passed it is decided that which same of same name is to be executed.

Monday, 10 June 2013

Drawbacks of Java

Following are some of the main drawbacks of Java:

a) Slow performance: The speed of execution is not too much fast. The designers of java are trying to increase its speed and are also trying to make its JIT(Just In Time )complier more efficient and fast.
 
b) No support for low-level programming: One more drawback of Java is that it cannot be used for writing  Low Level Programming Language as it is designed to develop code for the different platform. The java compiler takes the source code as input from the user. Compiles that code and generate an intermediate code which is platform independent.

c) Poor features in GUI: Java supports GUI controls but with very less features. For example, an image cannot be placed on a button. The is overcome with the introduction of javax.swing package.

d) No control over garbage collection: Garbage collection is one of the built-in features of Java and is entirely managed by JVM. programmer is not given any handles to control the garbage collection to make coding simple. For this reason, Java does not come with delete(), free(), malloc() and sizeof() etc. functions.
 

Tuesday, 4 June 2013

A simple Hello world Program



When we write a java program .. it is saved with the file name  ClassName.java(Make sure the extension is .java. the Classname.java file is compiled using the java compliler..
If the file complies successfully then a class file of the same name (Classname.class) will be generated.then the generated class file is executed .

SO lets start with the official "Hello world program"

Hello World Program

class HelloWorld    //Declare name of the main class, first lettershould becapital
{
public static void main(String arg[]])
{
System.out.println("Hello world");                     //Prints output on the screen
System.out.print("Welcome to Codsters, Clear your concepts and logics");
}
}


Java Introduction

Java is one of the most popular and most widely used programming language used in million of devices all around the globe. Java is widely used because of its features that it provides to the programmer can make applications and others software that provides easy and attractive user interface.

Java is an object oriented programming language that works on the basis of classes and objects. It follows bottom up approach during the execution of the program.

Following are some of the features of Java:

  • Inheritance : It is the process of creating the new classes and using the behavior of the existing classes by extending them to use the existing code and adding the additional features in the child class if needed along with the features of base class.Base classis the classfrom which the child class inherits or extends the features.

  • Encapsulation: : It is the mechanism of combining the information and providing the abstraction.

  • Polymorphism: :   It is the ability to take multiple forms, Polymorphism is the way of providing the different oprations to the functions having the same name but performing different tasks.

  • Dynamic binding :   It is the way of providing the maximum functionality to a program about the specific type at runtime.

  •  

    Wednesday, 15 May 2013

    A simple "Hello World" program

    #include<iostream.h>  //Header file
    #include<conio.h>
    void main()                // main function
    {
    cout<<"Hello World";
    getch();
    }



    See also:
    Find average of two numbers


                                              
    full details in json
    Proudly Powered by Blogger.