Wednesday, April 9, 2008

C++ Interview Questions - 11

C++ Interview Questions 11

1.In C++, what is the difference between method overloading and method overriding?

Overloading a method (or function) in C++ is the ability for functions of the same name to be defined as long as these methods have different signatures (different set of parameters). Method overriding is the ability of the inherited class rewriting the virtual method of the base class.

2.What methods can be overridden in Java?

In C++ terminology, all public methods in Java are virtual. Therefore, all Java methods can be overwritten in subclasses except those that are declared final, static, and private.

3.In C, what is the difference between a static variable and global variable?

A static variable declared outside of any function is accessible only to all the functions defined in the same file (as the static variable). However, a global variable can be accessed by any function (including the ones from different files).

4.In C, why is the void pointer useful? When would you use it?

The void pointer is useful becuase it is a generic pointer that any pointer can be cast into and back again without loss of information.

5.What are the defining traits of an object-oriented language?

The defining traits of an object-oriented langauge are:
encapsulation
inheritance
polymorphism

See more C / C++ Important Programs and Technical, HR Interview questions

6.Write a short code using C++ to print out all odd number from 1 to 100 using a for loop(Asked by Intacct.com people)
for( unsigned int i = 1; i < = 100; i++ )
if( i & 0x00000001 )
cout << i<<\",\";

7.ISO layers and what layer is the IP operated from?( Asked by Cisco system people)
Application, Presentation, Session, Transport, Network, Data link and Physical. The IP is operated in the Network layer.

8. Write a program that ask for user input from 5 to 9 then calculate the average( Asked by Cisco system people)
A.int main()
{
int MAX=4;
int total =0;
int average=0;
int numb;
cout<<"Please enter your input from 5 to 9";
cin>>numb;
if((numb <5)&&(numb>9))
cout<<"please re type your input";
else
for(i=0;i<=MAX; i++)
{
total = total + numb;
average= total /MAX;
}
cout<<"The average number is"<
return 0;
}

9. Can you be bale to identify between Straight- through and Cross- over cable wiring? and in what case do you use Straight- through and Cross-over? (Asked by Cisco system people)
A. Straight-through is type of wiring that is one to to one connection Cross- over is type of wiring which those wires are got switched

We use Straight-through cable when we connect between NIC Adapter and Hub. Using Cross-over cable when connect between two NIC Adapters or sometime between two hubs.

10.If you hear the CPU fan is running and the monitor power is still on, but you did not see any thing show up in the monitor screen. What would you do to find out what is going wrong? (Asked by WNI people)
A. I would use the ping command to check whether the machine is still alive (connect to the network) or it is dead.

Keep watching out PreviousPapers.blogspot.com for more C, C++, Java, ASP, NET and other computer languages important questions, programs and answers for technical interviews and other selection / admission interviews for freshers and students.


No comments: