C# Programming Language Practice Test

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By D_mahalakshmi
D
D_mahalakshmi
Community Contributor
Quizzes Created: 1 | Total Attempts: 579
| Attempts: 579 | Questions: 35
Please wait...
Question 1 / 35
0 %
0/100
Score 0/100
1. 1.     String a= "100"; int b = 10; ___________ What should be written to get the out put as 110? 

Explanation

To get the output as 110, the string variable "a" needs to be converted to an integer. This can be done using the Convert.ToInt32() method. Then, the integer variable "b" can be added to the converted integer value of "a" and stored in the integer variable "c". Therefore, the correct answer is c.Int c = Convert.ToInt32(a) + b.

Submit
Please wait...
About This Quiz
C# Programming Language Practice Test - Quiz

This C# Programming Language Practice Test assesses key skills in handling data types, parsing methods, and understanding object-oriented concepts like interfaces and arrays. It's designed for learners to... see moretest their C# proficiency, enhancing both academic and professional development. see less

2. 1. Write the keyword which can be used to declare parameter arrays?  

Explanation

The keyword "Params" can be used to declare parameter arrays.

Submit
3. 1. System Exceptions are handled by  

Explanation

System Exceptions are handled by CLR (Common Language Runtime). CLR is the runtime environment provided by the .NET framework that manages the execution of .NET programs. It is responsible for various tasks such as memory management, security, exception handling, and garbage collection. When a system exception occurs in a .NET program, CLR takes control and handles the exception by either terminating the program or providing appropriate error handling mechanisms. CLR ensures that the program's execution is managed in a safe and controlled manner, making it the correct answer for this question.

Submit
4. 1. What are the types of parameters?  

Explanation

The correct answer is "All the above" because all the mentioned options (out, ref, params, value) are types of parameters in programming. "out" parameters are used to pass data out of a method, "ref" parameters are used to pass data by reference, "params" parameters allow a variable number of arguments to be passed to a method, and "value" parameters are used to pass data by value. Therefore, all of these options are valid types of parameters.

Submit
5. 1. Which of the following jobs are done by Common Language Runtime?  

Explanation

The Common Language Runtime (CLR) is responsible for providing core services such as memory management, thread management, and remoting. It also enforces strict type safety to ensure that code is executed securely. Additionally, the CLR provides Code Access Security to protect against unauthorized access to system resources. Lastly, it provides Garbage Collection Services to automatically manage memory and deallocate objects that are no longer in use. Therefore, all of the given options are jobs done by the Common Language Runtime.

Submit
6. 1. Array is a abstract class. So It cannot have constructor---

Explanation

The statement is true because an abstract class cannot be instantiated, which means it cannot have a constructor. Abstract classes are meant to be extended by other classes, and their constructors are called when an instance of a subclass is created. Therefore, an abstract class itself does not need a constructor.

Submit
7. 1.     Array is a abstract class. So It cannot have constructor---

Explanation

The statement is true because an abstract class cannot be instantiated, meaning that objects of an abstract class cannot be created. Since a constructor is used to create objects, it is not allowed in an abstract class. Therefore, the given statement correctly states that an array, being an abstract class, cannot have a constructor.

Submit
8. 1. Which of the following statements are correct?  

Explanation

The conditional operator (?:) returns one of two values depending on the value of a Boolean expression. This operator is commonly used as a shorthand for an if-else statement. It evaluates the Boolean expression and if it is true, it returns the value before the colon (:), otherwise it returns the value after the colon. This allows for concise and efficient code when making decisions based on a condition.

Submit
9. 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);  

Explanation

The code snippet is using the Substring method in C#.NET to extract a portion of the string "ALL MEN ARE CREATED EQUAL". The method takes two parameters: the starting index and the length of the substring to be extracted. In this case, the starting index is 12 and the length is 3. So, the substring that will be extracted is "CRE". Therefore, the correct output for the code snippet is "CRE".

Submit
10. 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?  

Explanation

The .NET class libraries provide an extensible set of classes that can be used by any .NET compliant programming language. These libraries contain pre-built code that developers can use to perform common tasks, such as file input/output, database access, and networking. By using the .NET class libraries, developers can save time and effort by leveraging existing code rather than writing everything from scratch. Additionally, the .NET class libraries are designed to be language-agnostic, meaning that they can be used with any programming language that is compatible with the .NET framework.

Submit
11. 1. Which of the following is the incorrect form of Decision Control instruction?  

Explanation

The given code snippet is the incorrect form of a decision control instruction because it contains two "else" statements consecutively. In a valid decision control structure, there can only be one "else" statement following an "if" statement. The correct form would be to use "else if" for subsequent conditions.

Submit
12. 1. Int I =0; For(;i<10;) {//loop 1 I++; For(;i>9;i--) { //loop2 } } How many times loop gets executed?  

Explanation

The loop will execute infinitely because the condition for the first loop (i

Submit
13. 1. What is the difference between Convert.ToString(str) and str.ToString() method?  

Explanation

The correct answer is a. Convert.ToString(str) function handles NULL while str.ToString() does not. It will throw a NULL reference exception. This means that if the variable "str" is null, using Convert.ToString(str) will return an empty string instead of throwing an exception, while using str.ToString() will throw a NULL reference exception.

Submit
14. 1. which of the following statements are true about finally block?  (Choose 3)  

Explanation

The finally block is executed even if an error occurs, ensuring that any necessary clean-up jobs are performed. It is also definitely executed when leaving a try block, regardless of whether an error occurred or not.

Submit
15. 1.  Can an Interface be instantiated directly?  

Explanation

An interface cannot be instantiated directly because it is an abstract type that only defines the structure and behavior of a class. It cannot be used to create objects on its own. Instead, it is implemented by classes, which provide the necessary functionality. Therefore, the correct answer is "No."

Submit
16. 1. Which of the following statements is correct about the C#.NET code snippet given below?   int a = 10;  int b = 20;  int c = 30; enum color: byte {     red = a,      green = b,     blue = c    }  

Explanation

The given code snippet is defining an enum named "color" with three elements: red, green, and blue. The values of these elements are assigned using variables a, b, and c, which is not allowed in C#. Enum elements must have constant values, so variables cannot be assigned to enum elements.

Submit
17. 1. Which of the following is an 8-byte Integer?  

Explanation

The correct answer is "Long" because a Long data type in Java is an 8-byte integer. It can store values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Other options such as Char, Short, Byte, and Integer have smaller storage sizes and cannot hold values as large as an 8-byte integer.

Submit
18. 1. How many values is a function capable of returning?  

Explanation

A function is capable of returning only one value.

Submit
19. 1. What is the Difference between Convert.ToInt32 and Int.Parse?  

Explanation

Int.Parse and Convert.ToInt32 are both methods used to convert a string to an integer in C#. However, there is a difference between the two. Int.Parse cannot handle null values and will throw an ArgumentNullException error if it encounters a null value. On the other hand, Convert.ToInt32 can handle null values and will not throw an error in such cases. Therefore, the correct answer is b.Int.Parse Can't Handle Null values, It will throw an ArgumentNullException error.

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

Explanation

In an inheritance chain, the protected members of the base class are accessible to the derived class members. Protected members can be accessed by the derived class as if they were its own members. Additionally, the public members of the base class are also accessible to the derived class members. Public members can be accessed by any class, including the derived class.

Submit
21. 1. What is the size of a Decimal?  

Explanation

The size of a Decimal is 16 bytes. This data type is used to store decimal numbers with high precision and is commonly used in financial and monetary calculations. The 16-byte size allows for a larger range of values and more precise calculations compared to other numeric data types.

Submit
22. 1. Which of the following statements will correctly copy the contents of one string into another ?  

Explanation

The correct answer is "String s1 = "String"; String s2; s2 = String.Copy(s1);" because it uses the String.Copy() method to copy the contents of one string into another. This method creates a new string object with the same value as the original string.

Submit
23. 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;  

Explanation

The given code snippet contains an if statement with two conditions, age > 18 and no 18 is true. This is because the && operator is a short-circuiting logical operator, which means that if the first condition is false, the second condition will not be evaluated. The second correct statement states that the statement a = 25 will be executed if both conditions are true. Therefore, if age is greater than 18 and no is less than 11, the statement a = 25 will be executed.

Submit
24. 1.     If "real" data type is used in Database, whats  the equivalent datatype in C#-

Explanation

The equivalent data type in C# for the "real" data type used in a database is "Single".

Submit
25. 1. Statement 1: Console.ReadLine("---");        Statement 2: Console.In.Readline("---");         Both are same.

Explanation

Statement 1 and Statement 2 are not the same.

In Statement 1, the correct syntax is `Console.ReadLine("text");` where "text" is the prompt that will be displayed to the user. This method reads the input from the user as a string.

In Statement 2, `Console.In.Readline("text");` is not a valid syntax. The correct syntax is `Console.ReadLine();` without any arguments. This method also reads the input from the user as a string.

Therefore, the correct answer is False, as Statement 1 and Statement 2 are not the same.

Submit
26. 1. Which of the following can be declared in an interface?  (Choose 3)      

Explanation

In an interface, you can declare properties, methods, and events. An interface is a contract that defines a set of members that a class must implement. Properties allow you to define the characteristics or attributes of an object. Methods define the behavior or actions that an object can perform. Events allow objects to communicate with each other by sending and receiving notifications. Enumerations, structures, and other types of members cannot be declared in an interface.

Submit
27. 1. Which of the following can be facilitated by the Inheritance mechanism? (Choose 3)  

Explanation

The Inheritance mechanism allows for the use of existing functionality of a base class, which means that the derived class can inherit and utilize the methods and attributes of the base class. It also allows for the override of existing functionality of the base class, meaning that the derived class can modify or replace the methods or attributes inherited from the base class. Additionally, the Inheritance mechanism enables the implementation of new functionality in the derived class, allowing for the addition of new methods or attributes specific to the derived class.

Submit
28. 1. Is it possible to store multiple datatypes in System.Array  

Explanation

It is not possible to store multiple datatypes in System.Array. System.Array is a fixed-size collection that can only store elements of a single datatype. If we need to store multiple datatypes, we can use System.Collections.ArrayList which allows storing elements of different datatypes.

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

Explanation

The first statement is correct because function definitions cannot be nested in C#.NET. This means that you cannot define a function inside another function.

The second statement is correct because functions can be called recursively in C#.NET. This means that a function can call itself during its execution.

The fifth statement is correct because function calls can be nested in C#.NET. This means that a function can be called from within another function, creating a nested call structure.

Submit
30. 1. Which one of the modifiers declare a method to be class method?  

Explanation

The correct answer is "static". In Java, the "static" modifier is used to declare a method as a class method. Class methods are associated with the class itself rather than with any specific instance of the class. They can be called directly on the class without creating an object of the class.

Submit
31. 1. Which of the following statements are correct about data types?  (Choose 3)  

Explanation

The first statement is correct because each value type in C# has an implicit default constructor that initializes the default value of that type. The second statement is incorrect because value types cannot contain the null value, only reference types can. The third statement is correct because all value types in C# are derived implicitly from the System.ValueType class. The fourth statement is incorrect because in C#, local variables must be initialized before being used. The fifth statement is correct because variables of reference types are referred to as objects and they store references to the actual data.

Submit
32. 1. Which of the following statements are correct?  (Choose 2)  

Explanation

The correct answer is that we can assign values of any type to variables of type object and when a value type is boxed, an entirely new object must be allocated and constructed. This means that objects of any type can be stored in variables of type object, and when a value type is converted to object, it is boxed and a new object is created to hold the value.

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

Explanation

The correct answer is that the .NET CLR provides a language-neutral development & execution environment, ensures that an application would not be able to access memory that it is not authorized to access, provides services to run "managed" applications, and the resources are garbage collected. This means that the CLR allows developers to write code in multiple languages, enforces memory access restrictions, supports running applications that are managed by the CLR, and automatically frees up memory by garbage collecting unused resources.

Submit
34. 1. Which of the following statements are correct?  

Explanation

The first statement is correct because instance members of a class can only be accessed through an object of that class. The second statement is incorrect because a class can also contain static data and static member functions. The third statement is incorrect because objects created from a class can occupy different number of bytes in memory depending on their data members and the compiler's implementation. The fourth statement is correct because a class can contain Friend functions. The fifth statement is correct because a class is indeed a blueprint or template according to which objects are created.

Submit
35. 1. Which of the following statements are correct about the Bitwise & operator used in C#.NET?  

Explanation

The bitwise & operator in C#.NET can be used to put OFF a bit by performing a bitwise AND operation between two numbers, where the result will have the corresponding bit turned off if both bits are turned on. Additionally, the & operator can be used to check whether a bit is ON by performing a bitwise AND operation between the number and a mask where the bit of interest is turned on. If the result is not zero, it means the bit is ON. Similarly, the & operator can also be used to check whether a bit is OFF by performing a bitwise AND operation between the number and a mask where the bit of interest is turned off. If the result is zero, it means the bit is OFF.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 18, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 18, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Dec 27, 2011
    Quiz Created by
    D_mahalakshmi
Cancel
  • All
    All (35)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
1.     String a= "100"; int b = 10; ___________...
1. Write the keyword which can be used to declare parameter...
1. System Exceptions are handled by  
1. What are the types of parameters?  
1. Which of the following jobs are done by Common Language...
1. Array is a abstract class. So It cannot have constructor---
1.     Array is a abstract class. So It cannot have...
1. Which of the following statements are correct?  
1. Which of the following will be the correct output for the...
1. Which of the following components of the .NET framework...
1. Which of the following is the incorrect form of Decision...
1. Int I =0;...
1. What is the difference between Convert.ToString(str) and...
1. which of the following statements are true about finally...
1.  Can an Interface be instantiated directly?  
1. Which of the following statements is correct about the C#.NET...
1. Which of the following is an 8-byte Integer?  
1. How many values is a function capable of returning?  
1. What is the Difference between Convert.ToInt32 and Int.Parse?...
1. In an inheritance chain which of the following members of base...
1. What is the size of a Decimal?  
1. Which of the following statements will correctly copy the...
1. Which of the following statements are correct about the C#.NET...
1.     If "real" data type is used in Database,...
1. Statement 1: Console.ReadLine("---");...
1. Which of the following can be declared in an interface?...
1. Which of the following can be facilitated by the Inheritance...
1. Is it possible to store multiple datatypes in System.Array...
1. Which of the following statements are correct about functions...
1. Which one of the modifiers declare a method to be class...
1. Which of the following statements are correct about data...
1. Which of the following statements are correct?  (Choose...
1. Which of the following statements are TRUE about the .NET CLR?...
1. Which of the following statements are correct?  
1. Which of the following statements are correct about the...
Alert!

Advertisement