C# QB

Objective of the Course: (Why the course?) To provide a brief introduction to the .NET platform and C# programming langu...

6 downloads 259 Views 303KB Size
Objective of the Course: (Why the course?) To provide a brief introduction to the .NET platform and C# programming language constructs. Enlighten the students about object oriented programming, Exception handling, Interfaces, Delegates and events in C#. This course also gives a brief understanding of .NET Assemblies and garbage collection in C#.

Brief Course outline: (Main headings only) 1. 2. 3. 4. 5. 6. 7. 8.

The Philosophy of .NET, Building C# Applications C# Language Fundamentals Object-Oriented Programming with C# Exceptions and Object Lifetime Interfaces and Collections Callback Interfaces, Delegates, and Events Advanced C# Type Construction Techniques Understanding .NET Assembles

C# Question Bank Chapter1: Philosophy of .NET 1. What are the core features of .NET platform? 2. Write a program to compute and display the average of 3 numbers with input taken from the console. 3. How is C# better than VB, Java and C++,VB6 etc? explain 4. What are the building blocks of .NET platform? Briefly explain the role of CLS,CTS, CLR and base class libraries. 5. Explain the concept of assembly.What are its contents? 6. What are single file and multifile assemblies? 7. What is the significance of CIL or IL for the execution of any .NET aware language. Use appropriate language to support your answer. 8. Design a C# method AddInts( ) to add 5 integers that are read from key board. Send the result and a flag indicating successful addition or an error to the calling program say Main() . You must use appropriate parameter passing mechanism. 9. Explain the concept of namespaces. List and explain atleast 5 .NET namespaces. 10. How do you access a namespace programmatically. 11. What is the role of .NET type meta data? Give an example P E S I T SOUTH CAMPUS, BANGALORE,

Ms. Renuka

Course Information – BE. -VIISem

06CS/IS761

12. Explain CLR. Illustrate the work flow that take place between source code, given .NET compiler and the .NET execution engine. 13. Explain with a neat diagram relationship between .NET runtime layer and base class library? 14. Explain the formal definitions of all possible CTS types. 15. Explain the limitations and complexities found within the technologies prior to .NET .Briefly explain how .NET attempts to simplify the same. 16. Explain Jitter, along with its benefits. Explain how CLR host an application on .NET platform. Give the block diagram. 17. Explain the features of c# languages?

Chapter 2:. Building C# Applications 18. Explain how CSC. exe computer is used to build C # application. Explain any five flags with appropriate examples. (06Marks) 19. Write a program to count the number of object instances created inside or outside of an assembly. (08Marks) 20. With a program, demonstrate, how an assignment operation, between value types and reference types differ. 21. What are response files ? Why do you require them? Create a response file with a name TESTApp.rsp, and show how it is used to build applications 22. What are C# preprocessor directives? List all the C# preprocessor directives that are supported. Write a code snippet to illustrate any one of the C# preprocessor directives.? 23. How do you use response files. Explain with an example. 24. Write a program to count the objects created for a class. Define your own class. 8M 25. Explain the following aspects of VS.NET IDE: 10M a) Solution explorer b) running and debugging c) documenting code via XML 26. Which is the default response file ?. 27. What is cordbg.exe? List and explain any five command line flags recognized by crdbg.exe while running. Net assemblies under debug mode . 28. What do you mean by command line debugger? Write a C# code to compute square root of a number passed as command line argument 29. What is csc.rsp file? Where is it located? P E S I T SOUTH CAMPUS, BANGALORE,

Ms. Renuka

Course Information – BE. -VIISem

06CS/IS761

30. Mention the different preprocessor directives that C# supports. Explain each with examples. 31. Write a C# program to sort an array of integers using bubble sort 32. How do you create object instance in C#? with examples , describe default assignment of .NET data types 33. How do you format .NET strings and textual output? Give examples. 34. Write a C# program to display the current .NET development machine details. 35. Write a C# program to generate Fibonacci series up to N . value of N is read from console. 36. Design a simple calculator application that both adds and subtracts two integer variables, in C if as well as Visual Basic NET. What will be the nature of the CIL instructions emitted by both code? Explain the role of CIL and the benefits of CIL in the NET platform. Name the tool available in VS.NET for examining the assembly and investigate its contents. 37. Write a C# program to display the following information using system environment class a) Current directory of application 2) operating system version 3) logical drivers 4) host name 5) .NET version 38. Explain C# preprocessor directives: a) # region,# endregion b) conditional code compilation 39. Explain the following with respect to compilation of the C# program in command prompt a) Referencing external assemblies b) compiling multiple source files c) response files d) generating bug reports 40. Explain the following output options of the C# compiler csc.exe: 1) /out 2) /target:exe 3) /target:library 4) /target:module 5) /target:winexe 6) /doc 7) @ 8) /main

Chapter 3: C# Language Fundamentals 41. Give the difference between value types and reference types., shallow copy and deep copy? 42. Explain with examples the C# operators is, as and typeof. 43. What do you understand by params method of parameter passing. Give an example. 44. List and explain the various options available with C# compiler? 45. Why system.object is called master node? Explain 3 instance and static methods of system.object? 8M 46. Using methods in System.String class design a C# static method which replaces all occurrences of the word “vtu” with “VTU”. P E S I T SOUTH CAMPUS, BANGALORE,

Ms. Renuka

Course Information – BE. -VIISem

06CS/IS761

47. Design a C# program to design a structure: Student here, Branch is of type enum, with members. Add appropriate constructor and also a method to hike the marks by 10% t only CSE students. Show creation of some student objects and the way to call these methods. 48. Explain boxing and Unboxing with practical examples. 49. Explain the different method access modifiers. 50. Explain the different method parameter modifiers with examples. 51. What are the basic components of object oriented programming and how are they implemented? 52. Explain the following methods of System.String class with examples. a) compareTo b) insert c) replace 4) toUpper 53. How is Sytem.String class different from StringBuilder class? 54. Explain with appropriate examples of boxing and unboxing of structures. 55. Explain the concept of resolving name clashes across name spaces. 56. How do you define namespace aliases? 57. What are nested name spaces? 58. With an example explain what happens when reference type is passed by value and passed by reference 4M 59. Mention the different form of main methods in C# and explain why its type signature contains public and static keywords? 4M 60. Write a C# program to accept three numbers from command line, and print the biggest 05M 61. Write a program in C# to read a Jagged array and display the sum of all the elements of three inner arrays. 62. Write a C# program to arrange 5 names in ascending order. Names are obtained from command line arguments. 07M 63. List the methods in system.object master node. Explain functionalities of the methods Equals , T0 string Get Type 10M 64. Write a C# program for sorting and reversing an array of integers using methods in System.Array class. 65. Explain with examples constructor call forwarding using self reference

P E S I T SOUTH CAMPUS, BANGALORE,

Ms. Renuka

Course Information – BE. -VIISem

06CS/IS761

Chapter 4: Object Oriented Programming With C# 66. How do you call a base class constructor from a derived class? 67. How do you enforce encapsulation using accesors and mutators? Explain with examples, class properties and static properties in C#? 8M 68. Explain with example polymorphic support in C#? 69. What’s an abstract class? When do you absolutely have to declare a class as abstract? 70. Explain the two forms of relationships in C# inheritance with examples. 05M 71. In C# how do you determine whether a given base class reference is actually referring to a derived type or not? Illustrate with code snippets. 06M 72. Explain two ways to enforce encapsulation with examples. OR Explain the two techniques to preserve the integrity of state data in C#, illustarate with code snippets

7M

73. What are the three pillars of OOP in C#? Differentiate between “is-a” and “has-a” relation ship with programs? 8M 74. Explain the 2 different roles of “this” keyword with an example. 6M 75. Write a C# program to create a doubly linked list. Methods for inserting nodes at front end, deleting the node from the front end, and displaying the contents of the list. 10M 76. Explain the following with the suitable code A) Versioning of class members b) properties

10M

77. How is method overriding different from method overloading? With the help of code snippet explain the different ways a method can be overloaded? 78. Explain the two forms of inheritance with appropriate programs. 79. Enter two non-zero numbers. Write a program in C# if to display the highest common factor and the lowest common multiple

80. Explain with examples 1) sealed classes 2) abstract methods

P E S I T SOUTH CAMPUS, BANGALORE,

Ms. Renuka

Course Information – BE. -VIISem

06CS/IS761

81. Implement the following hierarchy of classes to demonstrate abstract functions in C#. Class employee: [Fields: name, Emp_id, Basic_sal, Methods: abstract method compute-Bonus( ) virtual method calculate - Sale ) ] Class manager: Derived from employee [Fields: Total_Sales Methods: comute_Bonus() to give - 5 % of basic Sal as bonus if Total_Sales> 10,000 - 2 % of basic Sal as bonus if Total~Sales < 10,000 Calculate_Sal() to calculate the salary as basic + 12% DA + Bonus. ] 82. Write driver program to create an array of 3 managers and display their total salary. Use appropriate constructors. (10 marks) 83. Write a program in C# to throw and handle the following exceptions in banking application. MinimumBalanceException : when balance is lets than 1000 ArgumentOutRangeException : If the amount deposited is greater than the capacity of an int. which in an argument to deposit function. Display the details of each exception. Use required members and methods to support the logic. (10Marks) 84. What is a property in C#? Why is it used? What is the advantage of using property over traditional accessor and mutator methods? . (O8Marks) 85. Define a person class with three data members: age, name and sex. . Create appropriate constructor. . Derive a class called employee from person that adds a data member code to store employee code. . Derive another class called specialist from employee. . Add a method to each of the derived class to display information about what it is. Write a driver program to generate an array of three ordinary employees and another array of three specialist and display information about them. Also display the information of the specialist by calling the method inherited from employee class. (10 Marks) 86. Write a C# application which defines a class shape, with four data members length, breadth, height and radius, appropriate constructors and methods to calculate the volume of cube, cone and sphere. Also, write shapeapp, which creates these 3 objects i,e.cube, cone and sphere using appropriate constructors and calculates their volume with the help of the above class methods.

P E S I T SOUTH CAMPUS, BANGALORE,

Ms. Renuka

Course Information – BE. -VIISem

06CS/IS761

(10Marks) 87.

Chapter 5: Exceptions And Object Life Time 88. What do u understand by exceptions in c#? 89. Write a C# program to Build a custom Exception which raises an Exception when the argument passed is a negative number. 90. How do u handle multiple exception. Illustrate with an example. 91. Write a program containing a possible exception use a try block to throw it and appropriate catch block to handle it properly. 92. What are system level Exception and Custom Level Exception? 93. What are the 3 approaches of building custom Exception? 94. Explain the concept of finalizing types. 95. Explain in detail garbage collection optimization. 96. Explain how garbage collection(g.c) works? 97. How do destructors and garbage collection work in C#? 98. Define bugs ,errors and exceptions with examples 3M 99. Name the two descendent classes of system.exception class and define their roles 3M 100. Mention the rule of thumb when you are constructing multiple catch blocks for a single try block, illustrate with code snippets. 05M

P E S I T SOUTH CAMPUS, BANGALORE,

Ms. Renuka

Course Information – BE. -VIISem

06CS/IS761

101. Mention the rules of .NET memory management and explain in detail how CLR performs a garbage collection 10M 102. List and explain core members of system.exception? explain following c# keywords 1) finally 2) using 10M 103. What do you mean by object life time? Explain the garbage collection optimization process in c#? 8M

104.

When does garbage collection occur. Explain the process of garbage collection and how it is

optimized in .NET? 10M 105.

Describe the role of .NET garbage collection, finalization, and Ad Hoc Destruction method

with examples 106.

8M

Mention the methods present in system.exception base class. Explain Targetsite, SyackTrace

properties 10M 107.

How to build custom exceptions in C#, explain using code 10M

108.

Explain the process of finalizing objects in .NET environment. Give the members of system.

GC and explain their usage, with examples. (09 Marks) '

109. Define a method that would sort an array of integers. Incorporate exception handling mechanism for "index out of bounds" situation. Develop a main program that employs this method to sort a given set of integers. 10M 110. Write a program in C# to throw and handle the following exceptions in banking application. MinimumBalanceException : when balance is lets than 1000 , ArgumentOutRangeException : If the amount deposited is greater than the capacity of an int. which in an argument to deposit function. Display the details of each exception. Use required members and methods to support the logic. (11 Marks) 111.

What is versioning of class members?

112.

When do you override the virtual system.object.Finalize() method? How do you implement

using destructor ? why do we avoid using destructor in C# applications? 06M 113.

Explain finalization process. How do you build adhoc destruction method?

114.

Explain the following terms, with an example, with

reference to C#

a) For each b) ref c) params d) enum

Chapter 6: Interfaces And Collections P E S I T SOUTH CAMPUS, BANGALORE,

Ms. Renuka

Course Information – BE. -VIISem

06CS/IS761

115.

How do you build clonable and comparable objects in C#. Give examples.

116.

Discuss IComparable interface?distinguish between IComparable and IComparer interfaces

117.

Design a Linked List class in C# with methods to insert and delete nodes. The list should

have the capability to store any type of data. 118.

Write a program that defines and implements an interface.

119.

How are interfaces different from Abstract base classes?

120.

What are the 3 ways to obtain interface references?

121.

What is explicit interface implementation? Explain with examples. Write a C# program to

implement enumeration data type? 122.

Explain the role of IClonable interface with an example.

123.

Explain the role of IComparable interface with an example. What is the use of IComparer

interface. 124.

How shallow copy and deep copy of an object is achieved in C#? write a program in C# to

demonstrate both 5M 125.

List the member functions of queue and stack classes. Write separate programs to

demonstrate both 08M 126.

Explain how interfaces can be used as polymorphic agents with suitable code. 8M

127.

List the interfaces of system.collections namespace and briefly explain their roles? 8M

128.

How to build cloneable and comparable objects in C#? 6M

129.

What is an interface? With a program demonstrate the implicit' and explicit access of interfaces. ,(08 Marks) Write a program in C# to sort an array of student objects having rollno, name and marks in two subjects. - display the array sorted on names - display the array based on average marks. (

130.

131.

Explain the following class types with examples i) ArrayList ii) Queue iii) stack

Chapter 7: Callback Interfaces, Delegates, and Events, Advanced Techniques 132.

Explain Single cast and multicast delegates in C# with examples.

133.

Draw a C# class to use delegates to sort an int array in ascending or descending order. You

must use the Comparator delegate Concept. P E S I T SOUTH CAMPUS, BANGALORE,

Ms. Renuka

Course Information – BE. -VIISem

06CS/IS761

134.

Write the steps involved in building a shared assembly under .NET environment.

135.

Write a note on events in C#.

136.

What are the ways to handle overflow and underflow conditions in C#? Mention the keyword

used. 137. How would you implement cloning using ICloneable interface? Distinguish between shallow and deep copy as applied to cloning 138.

Explain the unsafe code concept with example.

139.

How you will build a custom indexer. Illustrate with an example.

140.

Explain operator overloading in C#.

141.

Write a C# program to overload equality and comparison operators.

142.

Explain 1) callback interfaces 2) c# delegate keyword 3) c# event keyword

143.

Illustrate callback interfaces with a C# program 10M

144.

Write a C# program to illustrate how a delegate object is used to call methods dynamically

5M 145.

What are delegates in C#? Differentiate between synchronous and asynchronous delegates

with examples 10M 146.

What is .NET delegate type? Explain with the code 8M

147.

What is an indexer? Explain with examples differences between indexer and properties? 8M

148.

With example explain advanced keywords of C#:ckecked, unchecked, unsafe, stack alloc,

volatile,

10M

149.

What are delegates? Explain the members of system.'MulticastDelegates : Give a small , program to implant multicasting. (10Marks) ,

150.

Write a program in C# to implant operator over loading of + and - for adding subtracting two square matrices.

151.

Write a C# program to sort and reverse an array of 5 elements using sort() and reverse()

methods 5M 152.

Explain the following keywords 1) stackalloc 2) fixed 3) volatile 4) sizeof

153.

Write a complete C#program to calculate and display simple interest by writing appropriate methods which could be called through delegate method of programming.

P E S I T SOUTH CAMPUS, BANGALORE,

Ms. Renuka

Course Information – BE. -VIISem

06CS/IS761

Chapter 8: Understanding .NET Assemblies 154.

What are the problems with Classic COM binaries?

155.

What are the logical and physical views of assemblies?

156.

Explain the C# support for cross language inheritance, with examples 6M

157.

Explain in detail characteristics of assemblies.

158.

What do you understand by shared assemblies?

159.

What are strong names and what is it composed of?

160.

What is Assembly manifest? what all details the assembly manifest will contain?

161.

Explain C# iteration and control flow constructs with examples.

162.

Explain steps involved in building multifile assembly, with example 8M

163.

Explain shared and private assemblies in detail with proper examples 10M

164.

Explain the benefits of .NET assemblies. 5M

165.

Mention major elements of .NET binaries .explain each.

166.

Briefly explain types of views of an assembly 05M

P E S I T SOUTH CAMPUS, BANGALORE,

Ms. Renuka

Course Information – BE. -VIISem

06CS/IS761