Showing posts with label INTERVIEW QUESTIONS. Show all posts
Showing posts with label INTERVIEW QUESTIONS. Show all posts

Tuesday, 15 July 2014

What is Memory Allocation ? A Simple Answer.



MEMORY ALLOCATION ( DYNAMIC OR STATIC)


It all starts from a data that is stored in the memory , that data is given some memory .This Process of Giving memory is Called a memory allocation . The memory can be allocated in two manners : DYNAMICALLY AND STATICALLY .

STATIC MEMORY ALLOCATION 

-This memory allocation process reserves fixed mount of memory before actual processing takes place , and because of that , the number of elements to be stored must be predetermined . 
Such memory allocation process is  basically called as static memory allocation .

-The Arrays are allocated memory by this process only.


DYNAMIC MEMORY ALLOCATION

-This Type of memory allocation process gives allocation of memry during the program execution itself, as and when it is needed.This process of allocating memory is called  dynamic memory allocation .
-It also provides technique to release the memory , when memory is not required anymore.

-Data structures like Linked Lists and Tress use this very technique for their memory allocation.

Basics of Linked Lists , Stacks And Queues In C++


Linked Lists , Stacks And Queues


The very basic definitions that a person should know who is learning C++ are :

Linked ListsIT IS A  LINEAR COLLECTION OF DATA ELEMENTS , CALLED AS NODES POINTING TO THE NEXT NODES BY MEANS OF POINTER.

Stacks :  A STACK IS A LINEAR  STRUCTURE IMPLEMENTED IN LIFO (LAST IN FIRST OUT )MANNER WHERE INSERTION AND DELETIONS ARE  RESTRICTED TO OCCUR ONLY AT ONE END - THAT END IS SATCK'S TOP.

Queues: A QUEUE IS  ALSO A LINEAR DYNAMIC STRUCTURE IMPLEMENTED IN FIFO( FIRST IN FIRST OUT) MANNER WHERE INSERTIONS CAN OCCUR AT THE " REAR ' END  , AND THE BASIC DELETIONS OCCUR ONLY AT " FRONT" END.


IMPORTANT POINTS 

LIFO

-Means Element last inserted would be the first one to be deleted.

-The Stack is also  a DYNAMIC DATA STRUCTURE as it can grow( //with increase in number of elements //) or it can shrink(//with decrease in number of elements //).

FIFO:

-Means elements are deleted  in the same order as they are inserted into the queue.

Tuesday, 1 July 2014

Significance of access specifiers in a class in C++.



Significance of access specifiers in  a class


In C++ a class provides three access labels namely , private, protected and public.

A member declared as private or protected in C++ remains hidden from world and it can only be accessed by the member functions of the class itself. 

A member declared as public in C++ program is made available to the outside world. Basically it can accessed by any member functions of the class , by nay expression in the program but only by using a object of the same class type.

The labels listed enforces the data hiding  and abstraction, oop concepts  in C++ 

Compare default arguments and function overloading.




Compare default arguments and function overloading.


In C++ with the default arguments , the default values can be provided in the function prototype itself and the that function can be called even if the arguments are missing.
But there is one thing that should be considered that is , if you want to default a middle argument then all the arguments on its right must be defaulted.

And on the other side of this , you can overload a function for all possible argument combinations . It basically overcomes the limitation of default arguments but also the compiler is saved from the problem of testing the default value and pushing it on the function call stack. So with that compiler can process another thing.

Basic Concept of Function Overloading With Example


Concept of Function Overloading With Example


The very basic definition of function overloading in C++ is a function name having several definition that are differentiable by the number or the types of their arguments , is known as function overloading.


For Example 

The following example in which the code overloads a function area to find the values of area of circle ,rectangle and triangle.


float area(float r)
{
return 3.1*r*r;
}
float area (float len,float bre)
{
return len*bre;
}
float area(float side1, float side2, float side3)
{
float & = (side1+side2+side3)/2;
float ar = sqrt(&*(&_side1)*(&*(&_side2)*(&*(&_side3));
return ar;
}

Friday, 27 June 2014

Basic Definition of Polymorphism in C++ with example.




Definition of Polymorphism in C++ with example.



The basic definition of polymorphism in C++ is 

Polymorphism is the property by which the message can be sent to objects of several different classes , and each can respond to it in a different way depending upon its class. In C++ Polymorphism is itemplemend through the basic concept called as overloading.



Example  of polymorphism


float a ( float b)
{
return b*b;
}
float a ( float b, float c)
{
return b*c;
}

Definition of Inheritance in C++ with Example.

 

Inheritance in C++ with Example.




Inheritance in C++ is basically the capability of one class to inherit properties from another class . For example , house is a class wherefrom class chiarhouse inherits as given below:


class house
{
protected:
char name[25];
int rollno;
public:
void  readhouse ();
void showhouse ();
};
class chairhouse: protected house
{
protected :
char tables[50];
public:
 void readchahou();
void showchahou();
};
 

What are the advantages of OOP in C++.




Advantages of OOP in C++.




The Basic advantages of OOPs  in C++ are 

1.Reusability of code 

2. Ease of comprehension

3. Ease of Fabrication and Maintenance .

4.  Easy redesign and extension

Thursday, 26 June 2014

What are objects implemented in the C++.



 Objects implemented in the C++.



The basic details like the object implemented in C++ as in terms of the software are



1. Characteristics/attributes are implemented through member variables or from the data items of the object.

2. Behaviour is also implemented through member functions called methods.

3. It is always given a unique name to give its identification.

How can a Class enforce data- hiding, abstraction and encapsulation..

Class enforces data- hiding, abstraction and encapsulation..


What does a class actually do, it binds together data and its associated functions under one unit and because of that enforcing encapsulation as encapsulation means wrapping up of the data and associated functions together into a single unit .

And a Class groups its members into three sections : as private , protected and public.The members like private and protected remains hidden from the outside world.Thus through these private and protected members a  class enforces data hiding.

The Main function of the public member is only to give the important and essential information to the outside world and because of that rest things remain hidden , which is also called as abstraction. As it basically means representation of essentials features without including the background details .

Abstraction and Encapsulation in C++

Abstraction and Encapsulation in C++



Basically in C++ the shortest definition of these two can be is 


Abstraction

 Is the act of basically representing essential features without including the background details.

And


The Encapsulation

Is the way of combining both data and the functions that operate on the data under a single unit .

Encapsulation is the way of implementing abstraction.

Wednesday, 25 June 2014

Difference Between an Object and a Class in C++ .




An Object and  a Class in  C++

 The basic difference Between the Object and a Class in a C++ program is


Object 

An object is basically an identifiable entity with some characteristics and behaviour.

It also behaves as an entity that has the ability to store data and its associated functions.

Class 

A class in a C++ is basically a group of objects that share common properties and relationships.

And in another way can be said as a group of similar objects.




What are Object Oriented Programming and Procedural Prgramming in C++.




Object Oriented Programming and Procedural Programming in C++


The Basic Difference Between the Object Oriented Programming and Procedural Programming in C++  Is 



 Object Oriented Programming

1. Here the basic focus is on Objects.
2. This follows a Bottom - up approach in a program.
3.It's ability of data hiding feature prevents the accidental change in data.
4. The basic features of this type are data encapsulation,polymorphism and  inheritence.

  

Local Variables and Global Variables in C++


Local Variables and Global Variables



The Basic Difference Between the Local Variables and Global Variables is


Local Variables

1.  It is basically a variable which is declared with in a function or inside the block.

2. It is basically accessible only within a function or within a block in which it is declared .


Global Variables

1. It is basically a variable declared outside all the functions.

2. It is accessible throughout the program .


EXAMPLE :

Tuesday, 24 June 2014

What are Call by Value and Call by reference in C++ with Examples.




Call by Value and Call by reference in C++



Call by Value

In C++ the Call by Value method takes place , the called function creates its own copies of the original values that have been entered . 
Example of Call by value

int main()
{
int x =1;
cout<< "x="<<x;
ch(x);
cout<<"\n x="<<x;
return 0;
}
void ch(int b)
{
b=10;
}


Output


x=1;
x=1;

Any changes , that are made, occur on the called  function's copy of values  and are not reflected back to the calling function .

Call by Reference

In case of the Call by reference , the method accesses and works with the original values using their references. 

Any changes , that occur , take place on the original values and are reflected back to the calling code.




Example of Call by Reference 

int main()
{
int a = 1;
cout<< "x="<<x;
ch(a);
cout<<"\n x ="<<x;
return 0;
}
void ch(int &b)
{
b=10;
}

Output

x=1
x=10

Friday, 20 June 2014

TECHNICAL INTERVIEW QUESTIONS ON SQL / PLSQL-- SET 5





 INTERVIEW QUESTIONS ON SQL / PLSQL-- SET 5


1. The sql statement 

 SELECT  LAPD( 'abcd' ,10, 'wert')  FROM DUAL;

prints

(A) wertweabcd
(B)abcdwertwer
(C)wertwertab
(D)abwertwert



2.The sql statement 

 SELECT ROUND (45.926, -2) FROM DUAL;

(A) is illegal
(B)prints garbage
(C)prints 45.92
(D) prints 0





3.The sql statement 

 SELECT NVL(NVL(NULL, NVL(NULL, 3)) , 4)  FROM DUAL;

prints

(A) 3
(B)4
(C)NULL
(D) IS ILLEAGAL


TECHNICAL INTERVIEW QUESTIONS ON SQL / PLSQL-- SET 4






INTERVIEW QUESTIONS ON SQL / PLSQL-- SET 4




1. The sql statement

 SELECT LENGTH (' ') FROM DUAL ;  -- ''  is two single quotes

prints

(A)0
(B)a gargabe value
(C)NULL
(D) 1




2.The sql statement

 SELECT INSTR ( 'abcdecfg' , 'c')  FROM DUAL ;

prints

(A)2
(B)3
(C)5
(D) 6




3.The sql statement

 SELECT LPAD ('abcd' ,10,'*') FROM DUAL ;

prints

(A)abcd******
(B)*****abcd
(C)***abcd***
(D) *********