Members Bookmarks Fresher Jobs Strange Photos Academic Projects New Member FAQ  



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

Paid Surveys


website counter



C++ and Java Debugging-2


Posted Date: 16 May 2008    Resource Type: Articles/Knowledge Sharing    Category: Placement Papers

Posted By: Shanthi M       Member Level: Diamond
Rating:     Points: 1



Debugging – C++ & Java

1. What output is produced by the following program segment?

String name;
int i;
boolean startWord;
name = "Richard M. Nixon";
startWord = true;
for (i = 0; i < name.length(); i++)
{
if (startWord)
System.out.print (name.charAt(i));
if (name.charAt(i) == ' ')
startWord = true;
else
startWord = false;
}


2. What is the output?


class complex
{
double re;
double im;
public:
complex (): re (0), im (0) {}
complex (double n) {re=n, im=n ;}
complex (int m, int n) {re=m, im=n ;}
void print () {cout<};

void main ()
{
complex c3;
double i=5;
c3 = i;
c3.print ();
}


3. What is the output in the following program?
void main ()
{
char c=-64;
int i=-32
unsigned int u =-16;
if(c>i)
{
printf("pass1,");
if(cprintf("pass2");
else
printf("Fail2");
}
else{
printf("Fail1);
if(iprintf("pass2");
else
printf("Fail2");
}
}

4. What will be the result of the following program?
char *gxxx( )
{
static char xxx[1024];
return xxx;
}
void main( )
{
char *g="string";
strcpy(gxxx(),g);
g = gxxx();
strcpy(g,"old string");
printf("The string is : %s",gxxx());

}

5. What is the output?

#include

class fig2d
{
int dim1;
int dim2;

public:
fig2d () {dim1=5; dim2=6 ;}

virtual void operator<< (ostream & rhs);
};

void fig2d::operator<<(ostream &rhs)
{
rhs <dim1<<" "<dim2<<" ";
}

void main ()
{
fig2d obj1;

obj1 << cout;
}


Answers
1. R M N
2. 5 5
3. Fail1 Pass2
4. The string is: old string
5. 5 6













Responses

Author: Vidya    23 May 2008Member Level: Diamond   Points : 2
useful information


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: C Debugging-1
Previous Resource: Java Questions
Return to Discussion Resource Index
Post New Resource
Category: Placement Papers


Post resources and earn money!
 
Related Resources


Contact Us    Privacy Policy    Terms Of Use   

SpiderWorks Technologies Pvt Ltd. 2006 - 2007 All Rights Reserved.