Thursday, 20 September 2012

what are OOP concepts ??

OOP concepts are the concepts which are supposed to be satisfied by a programming language inorder to call that programming language as an Object-Oriented programming language.

since c programming language doesn't satisfy the three OOP concepts, we cannot call c as Object-Oriented programming language.

The three OOP concepts are:

1) Encapsulation
2) polymorphism
3) Inheritance

The birth of OOP concepts took place with encapsulation. Thus sometimes people call encapsulation as the backbone of OOP concepts.

what is the difference between static loading and dynamic loading ??

Static Loading:
The concept of allocating memory and loading the executable code of the functionality to the RAM before the function is called (or) before the program is under execution is known as static loading. static loading increases the overhead on the system. Thus, static loading is always disadvantageous.

Any structured programming language program would be based on the concept of static loading. Thus c programs would be working based on the concept of static loading.

Dynamic Loading:
The concept of allocating memory and loading the executable code of a function to the RAM dynamically at the run-time as and when a function call is made i.e., when the program is under execution , is known as dynamic loading.

Any object oriented programming language would be working based on the concept of dynamic loading. Thus java, works based on the concept of dynamic loading only. Dynamic loading reduces the overhead on the system. Thus, always dynamic loading is advantageous.

Sunday, 2 September 2012

what is First Normal Form ??

1. eliminate repeating groups in individual tables.
2. create a separate table for each set of related data.
3. identify each set of related data with a primary key.

what is normalization and for what it is meant for ??

Normalization is the process of organizing data in a database. This includes creating tables and establishing relationships between those tables according to rules designed both to protect the data and to make the database more flexible by eliminating two factors: redundancy and inconsistent dependency. 

Redundant data wastes disk space and creates maintenance problems. If data that exists in more than one place must be changed, the data must be changed in exactly the same way in all locations. A customer address change is much easier to implement if that data is stored only in the Customers table and nowhere else in the database. 

What is an "inconsistent dependency"? While it is intuitive for a user to look in the Customers table for the address of a particular customer, it may not make sense to look there for the salary of the employee who calls on that customer. The employee's salary is related to, or dependent on, the employee and thus should be moved to the Employees table. Inconsistent dependencies can make data difficult to access; the path to find the data may be missing or broken. 

There are a few rules for database normalization. Each rule is called a "normal form." If the first rule is observed, the database is said to be in "first normal form." If the first three rules are observed, the database is considered to be in "third normal form." Although other levels of normalization are possible, third normal form is considered the highest level necessary for most applications. 

Tuesday, 21 August 2012

What is a pure virtual function in C++ and abstract methods in JAVA?



A pure virtual function contains only method signature without any body( i.e., no implementation)
Example of pure virtual function in C++

class AbstractClass {
public:
   virtual void pure_virtualfunction() = 0;  // a pure virtual function - no body
   

};
Here "=0" may seems like 0 is assigned to the function, that is not true. It only indicates that the virtual function is pure virtual function and it has no body

Any base class that contains pure virtual function is abstract and cannot have an instance itself created and it also means that any class derived from the base class must override the definition of pure virtual function in the base classm if it doesn't, then derived class becomes abstract class as well.
In Java, pure virtual methods are declared using the abstract keyword. Such a method cannot have a body. A class containing abstract methods must itself be declared abstract. But, an abstract class is not necessarilly required to have any abstract methods. An abstract class cannot be instantiated.
In java we declare the class as abstract under two cenarios:
1) when the class contains abstract methods whose implementation will be provided later by its sub-  class.
2) whenever we don't want the object of a class to be created as sub-most object then we declare the class as abstract even if it doesn't contains any abstract methods.
EX: javax.servlet.http.HttpServlet class is declared as abstract even it doesn't contain any abstract methods.
In C++, a regular, "non-pure" virtual function provides a definition, so it doesn’t mean that the class that contains it becomes abstract. You would want to create a pure virtual function when it doesn’t make sense to provide a definition for a virtual function in the base class itself. Use a regular virtual function when it makes sense to provide a definition in the base class.
this link helped me  http://www.programmerinterview.com/index.php/c-cplusplus/pure-virtual-function/