Go to DotNetFunda.com
 Online : 1766 |  Welcome, Guest!   Login
 
Home > Interview Questions > C# Interview Questions > Class A { static byte a; static s ...

  • Download the OOPS, ASP.NET and ADO.NET Training Videos for FREE, click here.

call for mock interview

C# Interview Questions

Class A
{
static byte a;
static short b;
static char c;
static int d;
static long e;
static string s;

Public Static Void Main(String args[])
{
Console.WriteLine(a+b+c+d+e+s);
}

}

Author: Syedshakeer | Posted on: 2/20/2009 8:15:39 PM | Category: C# | Views:1721 |  Print | Asked In: Many Interviews

Select from following answers:
  1. 00000null
  2. 000000
  3. 0null
  4. 0

Show Correct Answer

Interesting?   Share and Bookmark this


 Response(s)
Posted by: Nirajagrawal | Posted on: 08 Mar 2009 11:16:42 PM

Brother,

First of all, I thank you for taking efforts in posting this question. I tried implementing this in one of the Console Applications and the output of:

Class A { static byte a; static short b; static char c; static int d; static long e; static string s; Public Static Void Main(String args[]) { Console.WriteLine(a+b+c+d+e+s); } }

is '0 ' and not '0null ' ... Please check it at your end and if possible modify your option ... it will help us guide people in the correct way.

According to me, the correct answer for this question is Option 4 and not Option 3.

No hard feelings ... we all are here to help each other !!!

Regards,

Niraj Agrawal

Posted by: Im4uonli | Posted on: 16 Mar 2009 05:22:13 AM

Niraj is right and I wonder that still the Person posted the Question has not changed the Answer to the Correct one i.e option D.
I think Bro You have guessed the answer logically and have not implemented it.

Posted by: Dmitriaa | Posted on: 12 May 2009 02:01:52 PM

The specification says the following.
"The binary + operator performs string concatenation when one or both operands are of type string. If an operand of string concatenation is null, an empty string is substituted. "

That explains why the correct answer is 0 (option 4).

Navigate to:

 Submit Interview Questions

what is Static? ...

What’s the advantage of using System.Text.StringBuilder over System.String? ...

Random Interview Questions
Help: If for some reason you are getting the same question by clicking Next Question or Previous Question, Try clicking Categories link above.

Related interview questions



Advertisement

About Us | The Team | Advertise | Contact Us | Feedback | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found copied contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
All rights reserved to DotNetFunda.Com. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks.
(Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher)