you can do more than what you think ……… if you believe you can

Post on 23-Jan-2016

23 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

You can do more than what you think ……… If you believe you can. Important Mantra. Do not Panic if you get a question which you do not know. Relax and the best tool to attempt for the answer is try using your common sense… You will not believe 80% of them manages to answer correctly. - PowerPoint PPT Presentation

TRANSCRIPT

You can do more than what you think ………

If you believe you can

Important Mantra

• Do not Panic if you get a question which you do not know.

• Relax and the best tool to attempt for the answer is try using your common sense…

• You will not believe 80% of them manages to answer correctly.

• Do not forget the word ATTITUDE at any point of your life.

• You are not the first• Maximum conversation time is 15-20 minutes• Make the interviewer bound to you never allow the

reverse to happen….But do this is very carefully and swiftly. Do not do it abruptly…

• And most of the questions are based on your previous answers….So the question paper is almost in your hands.

• Please Do not overload yourself till the last minute…

Plan yourself

Links used

• http://c-faq.com/~scs/cgi-bin/faqcat.cgi• http://www.techinterviews.com/c-interview-q

uestions-and-answers-2• http://zarrata.com/durofy/programming/10-

major-differences-between-c-and-c/• http://www.coolinterview.com/

Simple but yet asked many a times as refresh questions

• Programming language• Difference between Preprocessor, Compiler,

Assembler, Linker and Interpreter• Difference between C, C++ and Java• Features of OOPS• Definition about each of them

Frequently asked questions

• What is the difference between an ARRAY and a LIST?

• What is faster : access the element in an ARRAY or in a LIST?

• Define a constructor - what it is and how it might be called (2 methods).

• Describe PRIVATE, PROTECTED and PUBLIC the differences and give examples.

• What is a COPY CONSTRUCTOR and when is it called (this is a frequent question !)?

• Explain term POLIMORPHISM and give an example using eg. SHAPE object: If I have a base class SHAPE, how would I define DRAW methods for two objects CIRCLE and SQUARE.

• What is the word you will use when defining a function in base class to allow this function to be a polimorphic function?

• You have two pairs: new() and delete() and another pair : malloc() and free(). Explain differences between eg. new() and malloc()

• What is a callbyreference and callbyvalue?• Difference between calloc and malloc. what c in

calloc stand for?

Check list

• 1. Declarations and Initializations• 2. Structures, Unions, and Enumerations• 3. Expressions• 4. Pointers• 5. Null Pointers

• 6. Arrays and Pointers• 7. Memory Allocation• 8. Characters and Strings• 9. Boolean Expressions and Variables• 10. C Preprocessor

• 11. ANSI/ISO Standard C• 12. Stdio• 13. Library Functions• 14. Floating Point• 15. Variable-Length Argument Lists

Reference• malloc: malloc create the single block of given size by user

calloc: calloc creates multiple blocks of given sizeboth return void pointer(void *)so boh requires type castingmalloc: eg:int *p;p=(int*)malloc(sizeof(int)*5)above syntax tells that malloc occupies the 10 bytes memory and assign the address of first byte to P

calloc: eg:p=(int*)calloc(5,sizeof(int)*5)above syntax tells that calloc occupies 5 blocks each of the 10 bytes memeory and assign the address of first byte of first block to P

Other difference

• the above answer is absolutely right,but the difference between calloc and malloc is that calloc also initialize the reserved memory block to zero rather than garbage value in case of malloc()

1. What is the difference between an ARRAY and a LIST?Array is collection of homogeneous elements.

List is collection of heterogeneous elements.For Array memory allocated is static and continuous.

For List memory allocated is dynamic and Random. Array: User need not have to keep in track of next memory

allocation.List: User has to keep in Track of next location where memory is allocated.

2. What is faster : access the element in an ARRAY or in a LIST?• It’s array the reason is it continuous.

3. Define a constructor - what it is and how it might be called (2 methods).

constructor is a member function of the class, with the name of the function being the same as the class name. It also specifies how the object should be initialized.

Ways of calling constructor:1) Implicitly: automatically by complier when an object

is created.2) Calling the constructors explicitly is possible

4. You have two pairs: new() and delete() and another pair : alloc() and free(). Explain differences between eg. new() and malloc()

1.) “new and delete” are preprocessors while “malloc() and free()” are functions. [we dont use brackets will calling new or delete].

2.) no need of allocate the memory while using “new” but in “malloc()” we have to use “sizeof()”.

3.) “new” will initlize the new memory to 0 but “malloc()” gives random value in the new alloted memory location [better to use calloc()].

5. Explain term POLIMORPHISM and give an example using eg. SHAPE object: If I have a base class SHAPE, how would I define DRAW methods for two objects CIRCLE and SQUARE

POLYMORPHISM : A phenomenon which enables an object to react differently to the same function call.in C++ it is attained by using a keyword virtualexamplepublic class SHAPE{public virtual void SHAPE::DRAW()=0;}Note here the function DRAW() is pure virtual which means the sub classes must implement the DRAW() method and SHAPE cannot be instatiated

public class CIRCLE::public SHAPE{public void CIRCLE::DRAW(){// TODO drawing circle}}public class SQUARE::public SHAPE{public void SQUARE::DRAW(){// TODO drawing square}}

now from the user class the calls would be likeglobally

SHAPE *newShape;when user action is to draw

public void MENU::OnClickDrawCircle(){newShape = new CIRCLE();}

public void MENU::OnClickDrawCircle(){newShape = new SQUARE();}

when user actually drawspublic void CANVAS::OnMouseOperations(){newShape->DRAW();}

What is the word you will use when defining a function in base class to allow this function to be a polimorphic function?virtual

top related