C# Programming Language Practice Test

35 Questions | Attempts: 246
Share

SettingsSettingsSettings
C# Programming Language Practice Test - Quiz

Questions and Answers
  • 1. 
    1.     If “real” data type is used in Database, whats  the equivalent datatype in C#-
    • A. 

      Decimal

    • B. 

      Single

    • C. 

      Double

    • D. 

      None

  • 2. 
    1.     String a= “100”; int b = 10; ___________ What should be written to get the out put as 110? 
    • A. 

      A.Int c = a+b;

    • B. 

      B.String c = a + b;

    • C. 

      C.Int c = Convert.ToInt32(a) + b;

    • D. 

      D.Int c = Convert.ToInt32(a+b);

  • 3. 
    1.     Array is a abstract class. So It cannot have constructor---
    • A. 

      A.True

    • B. 

      B.False

  • 4. 
    1.  Can an Interface be instantiated directly?  
    • A. 

      A.Yes

    • B. 

      B.No

    • C. 

      C.It can be instantiated with static constructor

    • D. 

      D.None of these

  • 5. 
    1. What is the Difference between Convert.ToInt32 and Int.Parse?  
    • A. 

      A.Both are Same

    • B. 

      B.Int.Parse Can't Handle Null values , It will throws ArgumentNull Exception Error.

    • C. 

      C.Convert.ToInt32 Can't Handle Null Values ,it will throws ArgumentNullException error.

    • D. 

      D.Both can Handle Null Values

    • E. 

      E.Both can't Handle Null Values

  • 6. 
    1. What is the difference between Convert.ToString(str) and str.ToString() method?  
    • A. 

      A.Convert.ToString(str) function handles NULL while str.ToString() does not. It will throw a NULL reference exception.

    • B. 

      B.str.ToString() function handles NULL while Convert.ToString(str) does not. It will throw a NULL reference exception.

    • C. 

      C.Both can handle NULL

    • D. 

      D.None can Handle NULL

  • 7. 
    1. Which of the following statements are correct about the Bitwise & operator used in C#.NET?  
    • A. 

      The & operator can be used to Invert a bit.

    • B. 

      The & operator can be used to put ON a bit.

    • C. 

      The & operator can be used to put OFF a bit.

    • D. 

      The & operator can be used to check whether a bit is ON.

    • E. 

      The & operator can be used to check whether a bit is OFF.

  • 8. 
    1. Which of the following statements are correct?  
    • A. 

      The conditional operator (?:) returns one of two values depending on the value of a Boolean expression.

    • B. 

      The &* operator is also used to declare pointer types and to dereference pointers.

    • C. 

      In addition to being used to specify the order of operations in an expression, brackets [ ] are used to specify casts or type conversions.

  • 9. 
    1. Which of the following is an 8-byte Integer?  
    • A. 

      Char

    • B. 

      Long

    • C. 

      Short

    • D. 

      Byte

    • E. 

      Integer

  • 10. 
    1. What is the size of a Decimal?  
    • A. 

      4 byte

    • B. 

      8 byte

    • C. 

      16 byte

    • D. 

      32 byte

  • 11. 
    1. Which of the following statements are correct?  (Choose 2)  
    • A. 

      We can assign values of any type to variables of type object.

    • B. 

      When a variable of a value type is converted to object, it is said to be unboxed.

    • C. 

      When a variable of type object is converted to a value type, it is said to be boxed.

    • D. 

      Boolean variable cannot have a value of null.

    • E. 

      When a value type is boxed, an entirely new object must be allocated and constructed.

  • 12. 
    1. Which of the following statements are correct about data types?  (Choose 3)  
    • A. 

      Each value type has an implicit default constructor that initializes the default value of that type.

    • B. 

      It is possible for a value type to contain the null value.

    • C. 

      All value types are derived implicitly from System.ValueType class.

    • D. 

      It is not essential that local variables in C# must be initialized before being used.

    • E. 

      Variables of reference types referred to as objects and store references to the actual data.

  • 13. 
    1. Which of the following statements are TRUE about the .NET CLR?        (Choose which ever is correct)
    • A. 

      It provides a language-neutral development & execution environment.

    • B. 

      It ensures that an application would not be able to access memory that it is not authorized to access.

    • C. 

      It provides services to run "managed" applications

    • D. 

      The resources are garbage collected.

    • E. 

      It provides services to run "unmanaged" applications.

  • 14. 
    1. Which of the following components of the .NET framework provide an extensible set of classes that can be used by any .NET compliant programming language?  
    • A. 

      .NET class libraries

    • B. 

      Common Language Runtime

    • C. 

      Common Language Infrastructure

    • D. 

      Component Object Model

    • E. 

      Common Type System

  • 15. 
    1. Which of the following jobs are done by Common Language Runtime?  
    • A. 

      It provides core services such as memory management, thread management, and remoting.

    • B. 

      It enforces strict type safety.

    • C. 

      It provides Code Access Security

    • D. 

      It provides Garbage Collection Services

    • E. 

      All the above

  • 16. 
    1. Which of the following statements are correct about functions used in C#.NET?  (Choose 3)  
    • A. 

      Function definitions cannot be nested.

    • B. 

      Functions can be called recursively.

    • C. 

      If we do not return a value from a function then a value -1 gets returned.

    • D. 

      To return the control from middle of a function exit function should be used.

    • E. 

      Function calls can be nested.

  • 17. 
    1. How many values is a function capable of returning?  
    • A. 

      1

    • B. 

      0

    • C. 

      Depends upon how many params arguments does it use.

    • D. 

      Any number of values

    • E. 

      Depends upon how many ref arguments does it use.

  • 18. 
    1. Which of the following statements are correct?  
    • A. 

      Instance members of a class can be accessed only through an object of that class.

    • B. 

      A class can contain only instance data and instance member function.

    • C. 

      All objects created from a class will occupy equal number of bytes in memory.

    • D. 

      A class can contain Friend functions.

    • E. 

      A class is a blueprint or a template according to which objects are created.

  • 19. 
    1. Which of the following is the incorrect form of Decision Control instruction?  
    • A. 

      If (Condition1) {// Some statement}

    • B. 

      If (Condition1) {// Some statement} else {// Some statement}

    • C. 

      If (Condition1) {// Some statement} else {// Some statement} else if ( Condition2){//Some statement}

    • D. 

      If ( Condition1 ) {// Some statement} else if ( Condition2 ) {// Some statement} else {// Some statement}

    • E. 

      If ( Condition1 ) {// Some statement} else if ( Condition2 ) {// Some statement} else if ( Condition3 ) {// Some statement} else {// Some statement}

  • 20. 
    1. Which of the following statements are correct about the C#.NET code snippet given below? (Choose 3)   if (age > 18 && no < 11)     a = 25;  
    • A. 

      The condition no < 11 will be evaluated only if age > 18 evaluates to True.

    • B. 

      The statement a = 25 will get executed if any one condition is True

    • C. 

      The condition no < 11 will be evaluated only if age > 18 evaluates to False

    • D. 

      The statement a = 25 will get executed if both the conditions are True.

    • E. 

      && is known as a short circuiting logical operator.

  • 21. 
    1. Which of the following can be facilitated by the Inheritance mechanism? (Choose 3)  
    • A. 

      Use the existing functionality of base class.

    • B. 

      Overrride the existing functionality of base class.

    • C. 

      Implement new functionality in the derived class.

    • D. 

      Implement polymorphic behaviour.

    • E. 

      Implement containership.

  • 22. 
    1. In an inheritance chain which of the following members of base class are accessible to the derived class members? (Chhose 2)  
    • A. 

      Static

    • B. 

      Protected

    • C. 

      Private

    • D. 

      Shared

    • E. 

      Public

  • 23. 
    1. Which of the following will be the correct output for the C#.NET code snippet given below?   String s1 = "ALL MEN ARE CREATED EQUAL"; String s2; s2 = s1.Substring(12, 3);  Console.WriteLine(s2);  
    • A. 

      ARE

    • B. 

      CRE

    • C. 

      CR

    • D. 

      REA

    • E. 

      CREATED

  • 24. 
    1. Which of the following statements will correctly copy the contents of one string into another ?  
    • A. 

      String s1 = "String"; String s2; s2 = s1;

    • B. 

      String s1 = "String" ; String s2; s2 = String.Concat(s1, s2);

    • C. 

      String s1 = "String"; String s2; s2 = String.Copy(s1);

    • D. 

      String s1 = "String"; String s2; s2 = s1.Replace();

    • E. 

      String s1 = "String"; String s2; s2 = s2.StringCopy(s1);

  • 25. 
    1. which of the following statements are true about finally block?  (Choose 3)  
    • A. 

      Finally block is executed even if an error occurs

    • B. 

      Finally block is definitely executed when leaving a try block.

    • C. 

      Finally block is used to perform any necessary clean-up jobs.

    • D. 

      Finally block is not executed if an error occurs

Back to Top Back to top