.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Steve Jackman
Imran Ghani
Santhakumar Munuswamy

Home >> Interview Question >> C# >> Post New Question Subscribe to Interview Questions

What is the output of this?

Posted By :Syed Shakeer Hussain     Posted Date :February 20, 2009    Points :10   Category :C# 
What is the output of this

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);


The Numeric Sum of a,b,c,d,e is Zero.The Zero is converted to a string and concatenated with s.here s is Null

You can also find related Interview Question to What is the output of this?  below: 

Write and justify output of - select nullif('test','test')

The output will be - NULL
Justification : nullif returns NULl if given two arguments are same else returns the first specified argument. So, for the given SQL, output will be NULL. (More...)

What's the difference between Response.Write() andResponse.Output.Write()?

Response.Output.Write() allows you to write formatted output but Response.Write doesnt allow.

Example:Response.Output.Write("{0:d}", "Current Date Time: ", DateTime.Now) (More...)

What will be the output of this c program. ?
int x;
x = 200 * 200/200;

Answer = -127 { shocked }

Because 200 * 200 = 40000
and this can't be opted in int so goes on different side and later divided by 200

-25536/200 = -127.

What will be the output of this c program.

int a = 10, b = 20/3;
if(a == b );
printf("\n %d%d",a,b);


10,6 [just try] (More...)

What will be the output of this c program. ?

main ()

int i = 65;
char j ='A';
printf("\n %d %d",i,j);
printf("\n %c %c",i,j);
printf("God is Great");
printf("It's difficult fo judge");


65 65

God is Great

The output tells two things i.e. printf is capable of converting int into char and vice versa, and secondly if we compare int variable with char variable then ASCII value of that char variable is compared.

Cheers ! (More...)

Try to answer the output of this question.

main ()

if('Z' < 'z')
printf("\nINdia is on move.");
printf(\nIndians are loosing values.");


India is on move.
Because ASCII value of 'Z' is 90 which is less then the ASCII value of 'z'= 122 turns the if condition true. (More...)

Where is the output of TextWriterTraceListener redirected?

To the Console or a text file depending on the parameter passed to the constructor. (More...)

This is the progam using inheritence, what is the order of calling constructors and what is the output?
Public Class ConstructorEx
Public Class Class1
Dim a As Integer
Sub New()
a = 1
Console.WriteLine("a in initialized in Class1")
End Sub
End Class

Public Class Class2
Inherits Class1
Dim b As Integer
Sub New()
b = 1
Console.WriteLine("b in initialized in Class2")
End Sub
End Class
Public Class Class3
Inherits Class2
Dim c As Integer
Sub New()
c = 1
Console.WriteLine("c in initialized in Class2")
End Sub
End Class

Shared Sub main()
'Creation of the object of type Class3
Dim c As New Class3()
End Sub
End Class

In this example creation of the object of type class3 calls the Class3 constructor and that constructor calls Class2 Constructor Class2 Calls Class1 Constructor.So first Class1 constructor will execute and then control will be trasfered to class2 constructor,After executing the class2 constructor the control will be treansfered to Class3 constructor.

|---->Sub New()---------------------|
| 'First it will execute <-----|
| End Sub |
| |
| Class2 |
|--->Sub New()----------------------|
| 'Second it will execute<-------|
| End Sub |
| |
| Class3 |
----Sub New()-----------------------|
'Third this will executes<-----|
End Sub

Means In the Creation of the object of type C, First Class1 Constuctor initializes the data, then class2 then class3.

So output of this program is
a in initialized in Class1
b in initialized in Class2
c in initialized in Class3

Where is the output of TextWriterTraceListener redirected?

To the Console or a text file depending on the parameter passed to the constructor. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend