C#-1

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View C#-1 as PDF for free.

More details

  • Words: 558
  • Pages: 2
C# and .NET interview questions .NET

1.How big is the datatype int in .NET? 32 bits. 2.How big is the char? 16 bits (Unicode). 3.How do you initiate a string without escaping each backslash? Put an @ sign in front of the double-quoted string. 4.What are valid signatures for the Main function? lpublic static void Main() lpublic static int Main() lpublic static void Main( string[] args ) lpublic static int Main(string[] args )

5.How do you initialize a two-dimensional array that you don’t know the dimensions of? lint [, ] myArray; //declaration

lmyArray= new int [5, 8]; //actualinitialization

6.What’s the access level of the visibility type internal? Current assembly. 7.What’s the difference between struct and class in C#? lStructscannot be inherited.

lStructsare passed by value, not by reference. lStruct is stored on the stack, not the heap.

8.Explain encapsulation. The implementation is hidden, the interface is exposed. 9.What data type should you use if you want an 8-bit value that’s signed? sbyte. 10.Speaking of Boolean data types, what’s different between C# and C/C++? There’s no

conversion between 0 and false, as well as any other number and true, like in C/C++. 11.Where are the value-type variables allocated in the computer RAM? Stack. 12.Where do the reference-type variables go in the RAM? The references go on the stack, while the objects themselves go on the heap. 13.What is the difference between the value-type variables and reference-type variables in terms of garbage collection? The value-type variables are not garbage-collected, they just fall off the stack when they fall out of scope, the reference-type objects are picked up by GC when their references go null. 14.How do you convert a string into an integer in .NET? Int32.Parse(string) 15.How do you box a primitive data type variable? Assign it to the object, pass an object. 16.Why do you need to box a primitive variable? To pass it by reference. 17.What’s the difference between Java and .NET garbage collectors? Sun left the implementation of a specific garbage collector up to the JRE developer, so their performance varies widely, depending on whose JRE you’re using. Microsoft standardized on their garbage collection. 18.How do you enforce garbage collection in .NET? System.GC.Collect(); 19.Can you declare a C++ type destructor in C# like ~MyClass()? Yes, but what’s the point, since it will call Finalize(), and Finalize() has no guarantees when the memory will be cleaned up, plus, it introduces additional load on the garbage collector. 20.What’s different about namespace declaration when comparing that to package declaration in Java? No semicolon. 21.What’s the difference between const and readonly? You can initialize readonly variables to some runtime values. Let’s say your program uses current date and time as one of the values that won’t change. This way you declare public readonly string DateT = new DateTime().ToString(). 22.What does \a character do? On most systems, produces a rather annoying beep. 23.Can you create enumerated data types in C#? Yes.

24.What’s different about switch statements in C#? No fall-throughs allowed. 25.What happens when you encounter a continue statement inside the for loop? The code for the rest of the loop is ignored, the control is transferred back to the beginning of the loop. 26.Is goto statement supported in C#? How about Java? Gotos are supported in C#to the fullest. In Java goto is a reserved keyword that provides absolutely no functionality.

Related Documents

C1
April 2020 29
C1
October 2019 56
C1
November 2019 43
C1
December 2019 34
C1
May 2020 32
C1
June 2020 23