Showing posts with label difference between. Show all posts
Showing posts with label difference between. Show all posts

Tuesday, 24 June 2014

Difference Between Array and Collection

Difference Between Array and Collection



Array

Collection
 1. Size of arrays are fixed.  1. Size of collection are growable in nature we can increase or decrease the size as our requirement.
2. Memory point of view array concept not recommended to use.2. Memory point of view collection concept highly recommended to use.
3. Arrays can hold only homogeneous elements. 3. Collection can hold both homogeneous and heterogeneous objects.
4. Arrays can hold both primitives and objects type elements. 4. Collection can hold only objects.


Sunday, 22 June 2014

Difference Between Method Overloading and Overriding

Difference Between Method Overloading and Overriding


Method Overloading

Method Overriding
1. Method name must be same. 1. Method name must be same.
2. Method argument must be different. 2. Method arguments must be same.
3. Method signature must be different. 3. Method signature must be same.
4. Return type can be changed. 4. Return type must be same until 1.4v but after 1.5v co-variant type allowed.
5. Private , static and final method can be overloaded. 5. Private , static and final method can not be override.
6. Any type of access modifier is allowed(public ,  protected , private). 6. We can not decrease the scope modifier.
e.g. public method can not override as  protected.
7. There is no restriction in exception handling. 7. Child class should be handle exception same as the parent class or the child exception.

e.g. P: Exception
C: Exception or IOException
8. Method resolution takes by the compiler. 8. Method resolution takes by the JVM based on the object reference.
9. Method overloading also known as static polymorphism, compile-time polymorphism or early binding 9. Method overriding also known as dynamic polymorphism, run-time polymorphism or late binding




Saturday, 21 June 2014

Difference Between Abstract class and Interface

Difference Between Abstract class and Interface.

Abstract Class Interface
1. If we are talking about implementation but not completely (partially implementation) then go for abstract class. 1. If we does know anything about the implementation then we should go for the interface.
2. Every method present in abstract class need not be abstract ,it can be not abstract also. 2. Every method present inside interface is by default abstract.
3. Every method present in abstract class need not be public. 3. Every method present inside interface is by default public.
4. We can use any modifier for the method. 4. The following modifiers are not allowed for the interface methods:
Strictfp , protected , final , native , static , private , synchronized .
5. No restriction for abstract class variables. 5. Every attribute present inside the interface is by default public , static and final.
6. No restriction for the abstract class variables. 6. Following modifiers cannot declares for the interface variables
Private , protected , transient , volatile .
7. No restriction for the initialization of abstract class variables. 7. Compulsory initialize the variables whenever declaration.
8. Inside abstract class we can take instance and static block. 8. Inside interface we cannot take instance and static block.
9. Inside abstract class we can create constructor. 9. Inside interface we can not create constructor.


Difference Between C++ and Java

Difference Between C++ and Java

C++ Java
1. C++ is an extension of C with Object oriented behavior , C++ is not complete object oriented language as Java. 1. Java is complete object oriented language.
2. C++ supports pointer concept. 2. Java does not support pointer.
3. At compilation stage C++ source code converted into machine level code. 3. At compilation stage Java source code converted into byte code.
4. C++ is platform dependent , you have to compile and run program for different platform. 4. Java is platform independent language so you can compile once and run any where.
5. C++ uses only compiler. 5. Java uses both compiler and interpreter.
6. C++ supports operator overloading. 6. Java does not supports operator overloading.
7. C++ supports multiple inheritance. 7. Java does not supports multiple inheritance.
8. Goto statements available in C++. 8. There no goto statements concept in Java.
9. C++ supports :: scope resolution operator. 9. No :: scope resolution operator.
10. C++ does not have garbage collector concept. 10. Garbage collector is most useful feature of Java
11. C++ does not support final keyword. 11. Java supports final keyword.
12. C++ supports constant keyword. 12. Java does not supports constant keyword.
13. C++ uses #include to include different files. 13. Java uses import keyword to include different classes.




Difference Betwee C and C++

Difference Between C and C++


C

C++
1. C is Procedural Language. 1. C++ is non Procedural i.e Object oriented Language.
2. In C, Polymorphism is not possible. 2. The concept of polymorphism is used in C++.Polymorphism is the most Important Feature of OOPS.
3. Inheritance is not possible in C. 3. Inheritance is possible in C++.
4. Virtual Functions are not present in C. 4. The concept of virtual Functions are used in C++.
5. Operator overloading is not possible in C. 5. Operator overloading is one of the greatest Feature of C++.
6. Top-down approach is used in Program Design. 6. Bottom-up approach adopted in Program Design.
7. Multiple Declaration of global variables are allowed. 7. Multiple Declaration of global varioables are not allowed.
8. scanf() Function used for Input.
printf() Function used for output.
8. Cin>> Function used for Input.
Cout<< Function used for output.
9. Namespace Feature is not present in C. 9. Namespace Feature is present in C++ for avoiding Name collision.
10. In C, we can call main() Function through other Functions 10. In C++, we cannot call main() Function through other functions.
11. C requires all the variables to be defined at the starting of a scope. 11. C++ allows the declaration of variable anywhere in the scope i.e at time of its First use.
12. In C, malloc() and calloc() Functions are used for Memory Allocation and free() function for memory Deallocating. 12. In C++, new and delete operators are used for Memory Allocating and Deallocating.
13. C supports built-in and primitive data types. 13. C++ support both built-in and user define data types.
14. Mapping between Data and Function is difficult and complicated. 14. Mapping between Data and Function can be used using Objects
15. In C, Exception Handling is not present. 15. In C++, Exception Handling feature us available.