| Back to Questions Page |
| |
| Question |
What is the output of:
String a1 = "Hello";
String a2 = "world!";
String* s1 = &a2;
String& s2 = a1;
s1 = &a1;
s2 = a2;
std::cout << *s1 << " " << s2 << std::endl; |
Rank |
Answer Posted By |
|
Question Submitted By :: Seeker |
| This Interview Question Asked @ Lehman-Brothers |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Hello World  |
| Saranya |
| |
| |
| Answer | The output is
world! world!
This is becuase s2 is a reference variable of a1 and we are
assigning s2 value if a2 which is world!.
This is chnaging the value at a1 as well.  |
| Ratan |
| |
| |
| Answer | address of a1 hello  |
| Dsp |
| |
| |
|
|
| |
| Answer | world! world! is the right anwer.
Do not confuse with other asnwers.
Same is verified.  |
| Pokala |
| |
| |
| Question |
In C++ cout is:
a) object
b) class
c) something else |
Rank |
Answer Posted By |
|
Question Submitted By :: Seeker |
| This Interview Question Asked @ Lehman-Brothers |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Stream Object  |
| Sanjay Makwana |
| |
| |
| Answer | ANSWER IS C. COUT IS AN BUID IN OPERATOR THAT WAS DEFINED
IN HEADER FILE: <IOSTREAM.H>
SINCE, IN C++ COUT IS AN CONSOLE OUTPUT OPERATOR.  |
| Sriram |
| |
| |
| Answer | cout is an object of class ostream that represents the
standard output stream. It corresponds to the cstdio stream
stdout.
By default, most systems have their standard output set to
the console, where text messages are shown, although this
can generally be redirected.
Because cout is an object of class ostream, we can write
characters to it either as formatted data using for example
the insertion operator (ostream::operator<<) or as
unformatted data using the write member function
 |
| Chandra |
| |
| |
| Answer | Its an Object of class OStream, thats why we add its
corresponding header file that is <iostream.h>, Open this
header file you wil get complete infomation.  |
| Reejusri |
| |
| |
| Answer | The answer is someting else.
cout is an ostream opertor.  |
| Manju |
| |
| |
| Answer | C++ treats everything as an object.me,u,we,cout all are
object in C++.So cout is an object.  |
| Kiruthika |
| |
| |
| Answer | a, it is an object in C++  |
| Ganesh |
| |
| |
| Answer | ans is a) it is an object of ostream_withassign.  |
| Hemant Majithia |
| |
| |
| Answer | object of ostream_withassign. (a) is the right answer.  |
| Shakti Singh Khinchi |
| |
| |
| Answer | cout is an object.....  |
| Vaibhav Meena |
| |
| |
| Question |
Write a String class which has:
1) default constructor
2) copy constructor
3) destructor
4) equality operator similar to strcmp
5) constructor which takes a character array parameter
6) stream << operator |
Rank |
Answer Posted By |
|
Question Submitted By :: Seeker |
| This Interview Question Asked @ Lehman-Brothers , Zoomtrang |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | #include <iostream>
#include <string.h>
using namespace std;
class ownStrcmp
{
public:
ownStrcmp(){}
ownStrcmp(ownStrcmp& rhs);
ownStrcmp(char* instring){ _string = instring;}
void setString(char* instring){ _string = instring;}
char* getString(){return _string ;}
~ownStrcmp(){}
int operator == ( ownStrcmp &rhs);
private:
char* _string;
bool _ret;
};
ownStrcmp::ownStrcmp(ownStrcmp& rhs)
{
_string = rhs._string;
}
int ownStrcmp::operator == ( ownStrcmp &rhs)
{
_ret = true;
if(this == &rhs)
{
return _ret;
}
int i = 0;
while( _string[i] != NULL){ ++i;}
int stringLength = i;
for (int j=0;j<stringLength;j++)
{
if(_string[j]!=rhs._string[j]) _ret=false;
}
return _ret;
}
int main()
{
ownStrcmp string1("hello world");
ownStrcmp string2("hello world");
if (string1 == string2)
cout<<"result is true"<<endl;
else
cout<<"result is false"<<endl;
return 0;
}  |
| Stevewu |
| |
| |
| Question |
Write a function which takes a character array as input and
reverses it in place. |
Rank |
Answer Posted By |
|
Question Submitted By :: Seeker |
| This Interview Question Asked @ Lehman-Brothers , Vision Infotech |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | void reverse(char *a)
{
char tmp;
int len = strlen(a) - 1;
for (int i = 0; i < len/2; i++)
{
tmp = a[i];
a[i] = a[len - i];
a[len - i] = tmp;
}
}  |
| Gumnam |
| |
| |
| Answer | #include<iostream>
using namespace std;
void reverse(char *a)
{
char *tmp = new char[strlen(a)];
memset(tmp,0,strlen(tmp));
int a1 = strlen(a);
a1 =a1-1;
for (int i = a1;i>=0; i--)
{
tmp[a1-i] = a[i];
}
cout<<tmp<<" "<<strlen(tmp)<<endl;
}
void main()
{
char *name = "Xerox";
reverse(name);
}  |
| Arun |
| |
| |
| Question |
what is new modifier in C# |
Rank |
Answer Posted By |
|
Question Submitted By :: Govindhinge |
| This Interview Question Asked @ HCL |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | hi  |
| Kiran |
| |
| |
| Answer | C# allow redefinition of inherited methods in the derived
classes at the cost of hiding the inherited ones using new
modifier.  |
| Pratyaya Kumar Ghosh [STPL] |
| |
| |
| Answer | Mr.kiran this site is not for sending "hi" type nessages.
please dont misuse the site.
thanq  |
| Anna [STPL] |
| |
| |
| Answer | HEI ANNA
This site is not for commenting 'bout others answers.u were
the one who misused the site by commenting!!!!
thnx  |
| Rahul P.v [STPL] |
| |
| |
| Answer | hi Rahul,
what u did, are u not misusued?  |
| Viswanath [STPL] |
| |
| |
| Answer | When used as a modifier, the new keyword explicitly hides a
member inherited from a base class. Hiding an inherited
member means that the derived version of the member
replaces the base-class version.  |
| Shiraz Abbas Rizvi [STPL] |
| |
| |
| Question |
What is command routing in MFC |
Rank |
Answer Posted By |
|
Question Submitted By :: Varaprasadk |
| This Interview Question Asked @ GE |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Check the Command pattern in Gof books, MFC almost use it in
the same way:
SubWidget in the dialog will catch it firstly, it will
forward it to Parent window(the dialog) if *request is not
for it or no handler defined.
This procedure runs recursively, until one handle it or pass
it to application object. Application will omit unknown
command by default  |
| Bob |
| |
| |
| Question |
how to overload << and >> operator in c++ |
Rank |
Answer Posted By |
|
Question Submitted By :: Kumod |
| This Interview Question Asked @ Wipro |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | class chocoBox {
private:
int pieCount;
float boxPrice;
public:
// By giving default arguments, const acts like
// 0, 1 and 2 argument contructor
myClass(int pCount = 10, float bPrice = 20.0)
: pieCount(pCount), boxPrice(bPrice)
{ }
int getPieCount() { return pieCount; }
float getBoxPrice() { return boxPrice; }
void setPieCount(int pc) { pieCount = pc; }
void setBoxPrice(float bp) {boxPrice = bp; }
};
/* Lets overload the operator << of ostream class. We will
return a reference of ostream class for cascading calls
e.g. cout<<obj1<<obj2
*/
ostream& operator<< (ostream &stream, const myClass &obj)
{
stream<<obj.GetPieCount<<" "<<obj.GetBoxPrice<<endl;
return (stream);
}  |
| Manav Sharma |
| |
| |
| Answer | in c++ << and >> overloaded as the insertion and out put
symbole  |
| Abed |
| |
| |
| Answer | "<<" this inserssion perrator is used for output the
messages&values
">>"this exsersition operator is used for input the values
sentax:
return_type operator op(arguments_list)
{
----
----
}  |
| Ramya |
| |
| |
| Question |
pointers are support in C#? if yes then how to use it? |
Rank |
Answer Posted By |
|
Question Submitted By :: Jkreddy_peram |
| This Interview Question Asked @ Softvision-Solution |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | yes  |
| Varsha Vilas Kalebag |
| |
| |
| Answer | yes, pointer is nothing but value is saved in another
memory address  |
| Varsha Vilas Kalebag [Hawkeye Solutions] |
| |
| |
| Answer | pointers in C# are considered as unsafe code. We can use
pointers in the same way as we use in C++ or VC++ but we
need to build it with a /unsafe option  |
| Supratim Sengupta [Hawkeye Solutions] |
| |
| |
| Answer | NO
pointer is not used in c#  |
| Rajiv Grover [Hawkeye Solutions] |
| |
| |
| Answer | ya... pointer can be used in c# for value and array
types...and in inside class too (but class-> reference type
so not applicable)in the class members which are not ref
type../ using fixed keyword ... but it is unsafe....  |
| Rajavel [Hawkeye Solutions] |
| |
| |
| Question |
what is an array
|
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | array is an set od data types  |
| Varsha Vilas Kalebag |
| |
| |
| Answer | array i s the collection of similar data type it reduces
the unnecessary decleration of data types or variables
 |
| Abed |
| |
| |
| Answer | array is nothing but an array(a set ) of constants of
similar data type .  |
| Venu Gopal Raju |
| |
| |
| Answer | an array is a collection of elements of a single data type
stored in adjacent
<data_type><variable_name>[<dimension_size>];
ex:
int arr[5];  |
| Nekkanti Rajesh |
| |
| |
| Answer | An Array is set of related data items that shares a common
name.  |
| Hariharan,k |
| |
| |
| Answer | Array is a set of elements with homogeneous(same) data
type ,that stores elements consecutivly in memory location
and access of array elements is depending on the position
of elements in the array.  |
| Swamy S T |
| |
| |
| Answer | An Array is nothing but a collection of homogenous data of
fixed type.  |
| Shankar |
| |
| |
| Answer | array is a collection of homogeneous data items,that shares
a common name,this is stored in sequence memory.  |
| Malathi |
| |
| |
| Answer | array is a collection of elements  |
| Sivasankar |
| |
| |
| Answer | an array is a collection of elements with same data type.
it can also reduce the storage space  |
| Saranya |
| |
| |
| Answer | Array is a collection of variables of same data type stored
in contigious memory locations....  |
| Pradeep.v.s. |
| |
| |
| Answer | an array is a FIXED-SIZE sequenced collection of elements
of the same data type  |
| Chandrakanthvellanki |
| |
| |
| Question |
what is virtual function? |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
| This Interview Question Asked @ Infosys , Tcs, Hp |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | The virtual keyword means that method,property or function
can be overridden  |
| Jayakrishna Reddy |
| |
| |
| Answer | virtual function can be used to override the propertis of a
function.it is normaly used in inheritance. it is part of
polymerphism.  |
| Kumod |
| |
| |
| Answer | virtual function is ended with null
virtual function=o  |
| Varsha Vilas Kalebag |
| |
| |
| Answer | It allows one to write generalized code that works with the
base class pointer which can dynamically point to the
derieved class objects. Virtual function allows you to
implement runtime polymorphism. It allows the function call
to be binded with function definition as late as runtime.
Also read: concept of VPTR and VTABLE from Thinking in C++  |
| Manav Sharma |
| |
| |
| Answer | When derived class overrides the base class method by
redefining the same function, then if client wants to
access redefined the method from derived class through a
pointer from base class object, then you must define this
function in base class as virtual function.  |
| Manab |
| |
| |
| Answer | The objects of the polymorphic class, addressed by
pointers, change at runtime and respond differently for the
same message.Such mechanism requres postponment of binding
of a function call to the member function [ VIRTUAL] untill
runtime.  |
| Purba Phalguni Mishra, Gandhi |
| |
| |
| Answer | A virtual function is a function member of a class,
declared using the "virtual" keyword. A pointer to a
derived class object may be assigned to a base class
pointer, and a virtual function called through the pointer.
If the function is virtual and occurs both in the base
class and in derived classes, then the right function will
be picked up based on what the base class pointer "really"
points at.  |
| Aarti Ashar |
| |
| |
| Answer | A virtual function is basically a like normal function but
we can override the function in the derived classes.
Now when we want to access like (fn)
Base * bptr = new Derived();
bptr->fn(); then function of the derived class will be
called only if the function is marked as virtual in the
base class.
i.e the virtual keywork tells to use the function of the
class to which it is pointing to and not to the Base class.
This is called runtime polymorphism.  |
| Nk |
| |
| |
| Answer | The virtual function is nothing but the function in the
base class with the virtual keyword, that allows us to
derive only once in the class which is going to accsess it
while it is the child of two different classes which are
the child of the same base class.This is nothing but the
dynamic binding.  |
| Gomathisivaram |
| |
| |
| Answer | A virtual function is a function which is precedded by the
key word derived is declared in the base class.It is
normally used to achieve run time polymerphism.That means
we can override the base class function in the derived
class.We can invoke the virtual function through the base
class pointer depending upon the contents to which the base
class pointer points to.
Generally the implementation of virtual
class was found in inheritance where the base class
function is override in the derived class.  |
| Laxmikant |
| |
| |
| Answer | virtual function is used to prevent from more times
calling.That means if a function is declared as virtual
then its def will be diferent in base class & derived class  |
| Susanta Samal |
| |
| |
| Question |
Difference between over loading and over ridding?
|
Rank |
Answer Posted By |
|
Question Submitted By :: Sanglap |
| This Interview Question Asked @ CTS , Patni, Softvision Solution, Patni |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | overloading means when you define more than one function
with the same name but different with its signature.
over ridding means give the modified defination of the
inherited functions or methods.  |
| Azhar Iqbal |
| |
| |
| Answer | Overloading is nothing but compile time allocation where we
will come to know which method will be called. In this
method we can overload either a method or even operators
too.
Overridding is nothing but run time allocation. We being
programmers can let the program to deside which method
should be called during the execution. During comp time,
we will never come to know which object will call which
method. This can be achived by using VIRTUAL keyword.  |
| Shashikanth C R [None] |
| |
| |
| Answer | Overloading: Same function or operator responds differently
on different types on inputs. This is done by defining a
function (including operator fn() definition) with the same
name but different argument list.
Overriding: Redefining any base class function in a
derieved class to work differently than what is defined in
the base class. So, now the same function called with same
argument list will behave differently when called on the
objects of base and derieved class.
Important: Which instance of function to bind with the
object depends on the type of object on which the function
is called and is decided on compile time. This is also
called early binding or compile time polymorphism.  |
| Manav Sharma [None] |
| |
| |
| Answer | over loading is nothing but  |
| Varsha Vilas Kalebag [None] |
| |
| |
| Answer | overloading means one function name havimg different
arguements.
but overriding means the base as well as the derived class
havimg same function name  |
| Srabani [None] |
| |
| |
| Answer | Overloading means when we write diffrent fun. With the Same name & with diffrent singnature then it is called overloading . Overiding means both base & derived class has same name.  |
| Amit,mumbai [None] |
| |
| |
| Answer | Overloading:-Writing Two or three methods with same name
but different parameters in same class,it is called
methodOverloading.
Overriding:-writing same methodname and parameters in
subclass and superclass with same return type,it is called
methodoverriding.  |
| Nagababu [None] |
| |
| |
| Answer | Difference
Method OverLoading
1. Same method name with different number of argument
2. Number of argument with different datatype
3. Each method may returns different type of value
4. All overloaded methods founds to be in one class.
Method OverRiding
1. Same method name with same number of argument
2. Number of argument with same datatype
3. Each method must returns same type of value
4. Each overrided method of base class founds in respective
derived class.  |
| Rameshwar Gaikwad [None] |
| |
| |
| Answer | over loading : diff functns hvng same name are invoked
during the program whnever required by the programmer.
over ridding : gvs modified defination 2 d functns  |
| Imlepakshi [None] |
| |
| |
| Answer | Method Overloading is the method name looks similar but
return type and method arguement (inside parameter) differs.
Method Overiding is that the method name, arguements and
return type seems similar on both base and derived class.
(Sometimes we will add the additional code to the derived
class method also).  |
| Vasanth [None] |
| |
| |
| Question |
how to create thread in java? |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
| This Interview Question Asked @ Infosys |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | There are two methods available
1.by using extends keyword
2.by using interfaces  |
| Guest |
| |
| |
| Answer | It was created by extended from Thread class
and also we can create from interface thred  |
| Solanki |
| |
| |
| Answer | by extending thread class or by implementing runnable
interface  |
| Mohan |
| |
| |
| Answer | Their are specifically two different approaches to create
threads in Java:
1.By Extending thread class.
2.By Implementing runnable interface.  |
| Bijoy |
| |
| |
| Answer | It can also be created in number of ways.
1.Extended threadclass
2.Running thread  |
| Hari |
| |
| |
| Answer | we can do it in two ways.
one is by extending thread class and other is by
implementing Runnable interface.
here the later one is good because when we are going for
mutiple inheritance only interface helps us  |
| Vamsikrishna |
| |
| |
| Answer | There is two ways for creating Thread in Java:
1.Extending Thread class
2.Implementing Runnable Interface
Second one is much more benificial than 1st one,as we can
able to avoid the overriden methods.  |
| Bijoy Kumar Baral |
| |
| |
| Answer | There are two methods to create thread in java :
(1). By extending the Thread class.
(2). By implementing the Runnable interface.  |
| Rahul Madanan |
| |
| |
| Answer | Thread can be created by
1. Extending Thread Class
2. implementing Runnable interface
The second approach is better as if you want to use multiple
inheritance, interface is better option.  |
| Vijay Tandel |
| |
| |
| Answer | Thread can be created by tow way
1.interface
2.runnable interface  |
| Mask |
| |
| |
| Question |
When a private constructer is being inherited from one
class to another class and when the object is instantiated
is the space reserved for this private variable in the
memory?? |
Rank |
Answer Posted By |
|
Question Submitted By :: Neha |
| This Interview Question Asked @ Honeywell , Honeywell, HCL |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | constructors can not be inherited!
bcoz their work is to initialise the object of the class to
which they belong to!
so if they get inherited,how can they initialise the object
of the derived class!  |
| Uttama |
| |
| |
| Answer | yes  |
| Varsha Vilas Kalebag |
| |
| |
| Answer | yes.  |
| Vatsa |
| |
| |
| Answer | How do u expect a private part of a class to be inheritable
Do u have any code to support your views
I am ready to solve the same  |
| Kamlesh |
| |
| |
| Answer | The question is very absurd. From where did we get the
variable stuff? And ya, how on earth do we get private
members/functions being inherited? Kamlesh is right in
saying that The whole idea stinks.  |
| Karandeep Malik |
| |
| |
| Answer | before invoking derived class constructor base-class
constructor should be called.
1. first base-class object will be created then derived-
class object will be created.
2. here the base class constructor is private, so derived-
class cannot invoke it.
No object is created in derived-class.  |
| Balakishore |
| |
| |
| Answer | Private Constructor is not inherited.
When private member varible is not inherited but the size is
occupid in dervied class object.
e.g.
#include <iostream.h>
class A
{
int x;
int y;
};
class B : private A
{
};
int main()
{
cout << sizeof(B);
}
output :
8  |
| Sanjay Makwana, Puna |
| |
| |
| Answer | Neha, your question is not proper, please edit that. Some
where inheritance of private constructor and some where
private variable.
Please edit it so that people can help you.  |
| Reejusri |
| |
| |
| Answer | When a constructor is made private, object of that class
can not be created. That is called as Abstract class.
constructors can not be inherited. Moreover, when this
class is inherited, the base class object can not be
created. So we can not create the derived class object
also.  |
| Veena |
| |
| |
| Answer | When a constructor is made private, object of that class
can not be created. That is called as Abstract class.
constructors can not be inherited. Moreover, when this
class is inherited, the base class object can not be
created. So we can not create the derived class object
also.
the above ans is irrelevant to the current situation,
here the thing is, a constructor cannot b private coz there
is no use of .
but if a situation occurs as such in the given prob, yes the
space is reserved for that useless private constructor.  |
| Sillu Nu Oru C Coder |
| |
| |
| Answer | constructors cannot be private.  |
| Nk |
| |
| |
| Answer | public class TrialClass
{
protected int i, j;
public TrialClass(int one, int two)
{
i = one;
j = two;
}
public TrialClass(int joo)
{
}
public int squareArea()
{
int side1;
int side2;
side1 = i;
side2 = j;
return side1 * side2;
}
}
public class myDerivedClass : TrialClass
{
int rd;
int dr;
public myDerivedClass(int Age, int ages):base(Age)
{
rd = ages;
dr = Age;
}
}
Try making the base class single parameterized constructor
private.You will get your answer.  |
| Ankur Sehgal |
| |
| |
| Question |
c# support late binding or early binding. |
Rank |
Answer Posted By |
|
Question Submitted By :: Raj |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | yes c# support late binding or early binding  |
| Babu Khatri Bhai |
| |
| |
| Answer | yes it supports both depends  |
| Rakesh |
| |
| |
| Answer | Early binding is when your client app can detect at compile
time what object a property or method belongs to. Since
it "knows", it resolves the references and the compiled
executable contains only the code to invoke the object's
properties, methods, events, etc.
This is a good thing if you want to speed because the call
overhead is greatly reduced.
Late binding is the slowest way to invoke the properties
and methods of an object. You use late binding when you
write a function that uses an object variable that acts on
any of several different class objects. Since the compiler
doesn't "know" what class object will be assigned to the
variable, it doesn't resolve the references into the
compiled executable. In this case they are resolved at
runtime... when you actually have an assigned object to
reference the properties and methods to.
Hope this helps.  |
| Santu Sarkar |
| |
| |
| Question |
Give the output of the following program
main()
{int ret;
ret=fork();ret=fork();ret=fork();ret=fork();
if(!ret)
printf("sun");
else
printf("solaris"); |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
| This Interview Question Asked @ Sun-Microsystems |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | sunsolarissunsolarissunsolarissunsol  |
| Tajul Bashar |
| |
| |
| Answer | I dont't think this will compile as its missing a closing
brace.  |
| Imran |
| |
| |
| Answer | It depends on the return value of fork(). If it is other
than 0 (zero), then the output is solaris else sun.  |
| Pdp |
| |
| |
| Answer | Imagining that the correct headers were included and the
closing bracket for the main function is added, it'll print
sun 8 times and solaris 8 times. You won't know the order
that they're printed in, it depends on the kernel scheduler
as to which process is run first.  |
| Rojoco |
| |