Yahoo Interview Question Software Engineer / Developers




Comment hidden because of low score. Click to expand.
0
of 0 vote

Reference is to one object can not be changed to another object
Reference should be initialized always.

Any other Differences??

- Anonymous on November 21, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

POINTER

1) Its not necessary to initialize the pointer at the time of declaration. Like

int a = 10;

int *P = &a; //It is not necessary

Another way is :

int a = 10;

int *P;
P = &a;

2) You can create the array of Pointer.

3) You can assign NULL to the pointer like

int *P = NULL; //Valid

4) You can use pointer to pointer.

REFERENCE

1) Its necessary to initialize the Reference at the time of declaration. Like

int &a = 10;

int &a; //Error here but not in case of Pointer.

2) You can not create the Array of reference.

3) You can not assign NULL to the reference like

int &a = NULL; //Error

4) You can not use reference to reference.

- Anonymous on November 27, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Is reference a pointer?

* Reference is an implicit pointer
* Must tell it which variable it will become an alias for
* References do not require dereferencing
* No acquisition of memory address required
* References are often implemented by the compiler writers as pointers.
* References are "safer"


Is there any adv of references over pointers?

* References do not require dereferencing
* No acquisition of memory address required
* References are "safer"

Is there any adv of pointers over references? (yes, both this and the last qn is valid)

* Pointer can be left uninitialized.
* Pointer can be stored in Container classes, References cannot, as they are uninitialized.
* Most programs has "NULL" values, Pointers are recommended in these cases.
* Pointer can easily visualize side-effect is local or not.

- Ankush Bindlish on November 27, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

also pointer arithmetic

- amm on February 25, 2011 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book walking you through getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More