You are on page 1of 15

1.

Statement A: All the objects of a class share the same copy of the member functions but they maintain a separate copy of the member variables in memory. Statement B: The member functions of the class are accessed through an object of the class by using the "." operator. Identify whether the preceding statements are true or false. Choose one answer. A. Both statement A and statement B are false B. Statement A is false and Statement B is true C. Statement A and Statement B both are false D. Both statement A and statement B are true 2. Which of the following symbols can be used while naming a variable in C#? Choose one answer. A. [ B. * C. + D. _ 3.What will be the output when the following code snippet is executed? int[] score=new int[5] {2,4,6,8,10}; int i; for(i=0;i<5;i++) { ++score[i]; Console.WriteLine(score[i]); } Choose one answer. A. 12345 B. 357911 C. 246811 D. 246810 4.Consider the following code snippet: string str1, str2; str2 = "Students:"; int a = 40; str1 = str2 + Convert.ToString(a); What will be the value of str1?

Choose one answer. A. Str2: a B. Str2 40 C. Students:40 D. 40 5.consider the following code class inc_demo { void acc(ref int a) { a++;//line1 ++a;//line2 --a;//line3 a--;//line4 } public static void Main() { inc_demo obj = new inc_demo(); int x =8; obj.acc(ref x); Console.WriteLine(x); } } What will be the output if line4 is interchanged by line1? Choose one answer. A. 5 B. 8 C. 6 D. 7 6. Consider the following code: public delegate void specifictime(); private event specifictime alarm; A user is creating a class 'a' which contains a method "hello". He wants that everyday at some specific time that method should be called. So he implements it using events.

Choose the correct code written by him, which shows how "class a" subscribes to the event named specifictime. Choose one answer. A. a obj = new a(); alarm obj1= new specifictime(obj.hello); B. a obj = new a(); alarm = new specifictime(obj.hello); C. a obj = new a(); hello = new specifictime(obj.); D. a obj = new a(); alarm obj1= new specifictime(obj1.hello); 7. Consider the following scenario: Mark a software developer in Hi-Tech Technologies is presently working on the project of hotel management. In this project he needs to create a class named Top_Management. This class shows the functionality of the CEO, the chairman, and the managing director (MD) of the organization. The TOP_Management class analyzes the data provided by the other managerial classes in the organization. Therefore, the data analyzed by the top management needs to be confidential and the TOP_Management class must not be extended further by any other class. Identify the keyword to be used in the preceding scenario to keep the data in the TOP_Management class confidential. Choose one answer. A. virtual B. sealed C. interface D. abstract 8. Which of the following options can be used for accessing the nth element of an array named Arr? Choose one answer. A. Arr[n+1] B. Arr[n/2] C. Arr( n ) D. Arr[n-1] 9. Consider an employee object. Each employee object has an ID number. Which characteristic of the employee object is represented by the ID number?

Choose one answer. A. State B. Behavior C. Identity D. Both, Behavior and Identity 10. Marks: 1 Consider the following Statements: Statement A: An Interface can extend from zero or more Interfaces. Statement B: An Interface defines properties, methods, and events, which are known as the members of the interface. Which of the following is True, with respect to the above statement?

Choose one answer. A. Statement A is false and statement B is true. B. Statement A is true and statement B is false. C. Both, Statement A and Statement B are false. D. Both, Statement A and Statement B are true. 11. Consider the following statements: Statement A: Namespaces help you to create logical groups of related classes and interfaces. Statement B: Namespaces can be used to avoid any naming conflict between the classes that have the same names. Which of the following is true, with respect to the above statements?

Choose one answer. A. Both, Statement A and Statement B, are True. B. Both, Statement A and Statement B, are False. C. Statement A is False and Statement B is True. D. Statement A is True and Statement B is False. 12.Consider the following Statements: Statement A: Generalization is implemented using abstract classes. Statement B: Reusability is an important factor for composition relationship. Which of the following is True, with respect to the above Statements?

Choose one answer. A. Both, Statement A and Statement B, are True. B. Statement A is False and Statement B is True. C. Both, Statement A and Statement B, are False. D. Statement A is True and Statement B is False. 13. Consider the following Statements: Statement A: Inheritance refers to sharing of attributes and behaviors among classes based upon hierarchical relationship. Statement B: Inheritance enables you to create a generalized class and then derive more specialized classes from it. Which of the following is True, with respect to the above Statements?

Choose one answer. A. Both, Statement A and Statement B, are False. B. Statement A is False and Statement B is True. C. Statement A is True and Statement B is False D. Both, Statement A and Statement B, are True 14. Consider the following statements: Statement A: Inheritance refers to sharing of attributes and behaviors among classes. Statement B: When polymorphism is used in the context of operators behaving differently, depending on what they are operating on, it is referred to as operator overloading. Which of the following is true, with respect to the above statements?

Choose one answer. A. Both, Statement A and Statement B, are True. B. Both, Statement A and Statement B, are False. C. Statement A is False and Statement B is True. D. Statement A is True and Statement B is False. 15. Consider the following Statements: Statement A: Delegates allow you to specify the method to be invoked at runtime. Statement B: Delegates are reference type variables. Which of the following is True, with respect to the above Statements?

Choose one answer. A. Statement A is True and Statement B is False. B. Statement A is False and Statement B is True. C. Both, Statement A and Statement B, are False. D. Both, Statement A and Statement B, are True. 16. Predict the output of the following code: namespace Number { class Calculator { static int number1, number2, product; public void MultiplicationNumber() { product = number1*number2; Console.WriteLine("The Result is {0}", product); } Calculator () { number1=20; number2=30; product=0; Console.WriteLine ("Constructor Invoked"); } ~Calculator () { Console.WriteLine ("Destructor Invoked "); } static void Main(string[] args) { Calculator c1=new Calculator (); c1.MultiplicationNumber(); } }

} Identify the constructor and destructor from the preceding code.

Choose one answer. A. Calculator is the constructor. MultiplicationNumber() is the destructor. B. MultiplicationNumber() is the constructor. Calculator is the destructor. C. Calculator() is the constructor. ~Calculator is the destructor. D. ~Calculator is the constructor. Calculator() is the destructor. 17. Which data type can be used for a variable that stores the grade of a student in a particular exam, where the grades can be A, B, or C?

Choose one answer. A. char[] B. float C. char D. int 18. Consider the following code: using System; namespace p { class one { public int a,b; public void one() { a=b=0; } public void one(int a1,int b1)

{ a=a1; b=b1; } public void display() { Console.WriteLine("value 1={0}",a); Console.WriteLine("value 2={0}",b); } } class cons_demo1 { static int Main(string[] args) { one obj = new one(); obj.display(); one obj1 = new one(20,30); obj1.display(); return 0; } } } The above code is generating an error. Which of the following the code snippet is correct to implement the constructor overloading?

Choose one answer. A. class one { public int a,b; public one() { a=b=0; } public one(int a1,int b1) {

a=a1; b=b1; } public void display() { Console.WriteLine("value 1={0}",a); Console.WriteLine("value 2={0}",b); } } B. class one { public int a,b; public int one() { a=b=0; } public void one(int a1,int b1) { a=a1; b=b1; } void display() { Console.WriteLine("value 1={0}",a); Console.WriteLine("value 2={0}",b); } } C. class one { public int a,b; public void one() { a=b=0; } public one(int a1,int b1)

{ a=a1; b=b1; } public display() { Console.WriteLine("value 1={0}",a); Console.WriteLine("value 2={0}",b); } } D. class one { public int a,b; one() { a=b=0; } int one(int a1,int b1) { a=a1; b=b1; } public void display() { Console.WriteLine("value 1={0}",a); Console.WriteLine("value 2={0}",b); } } 19. Which of the following code snippets can be used for declaring a class named student containing two variables, marks and roll number. The code should create 60 objects of class Student, one object per student.

Choose one answer.

A. class student { public int marks; public int rollNumber; static void Main() { class student=new list[60]; } } B. class student { public int marks; public int rollNumber; static void Main() { student[] list=new student[60]; } } C. class student { public int marks; public int rollNumber; static void Main() { student list; } } D. class student { public int marks; public int rollNumber; student list[60]; } E. None of the above

20. A teacher wants to explain the concept of sleep() method in the life cycle of a thread. Which of the following is the correct code?

Choose one answer. A. class thrd { public static void child() { int st =5000; Console.WriteLine("sleeping for {0} sec",st,1000); Thread.Sleep(st); } } B. class thrd:Thread { public static void child() { int st =5000; Console.WriteLine("sleeping for {0} sec",st,1000); Thread obj = new Thread(Sleep()); } } C. class thrd:Thread { public static void child() { int st =5000; Console.WriteLine("sleeping for {0} sec",st,1000); ThreadState.Sleep(st); } } D. class thrd { public static void child()

{ int st =5000; Console.WriteLine("sleeping for {0} sec",st,1000); ThreadState.Sleep(st); } } 21. A class named class1 contains four contructors: class1(), class1(int x), class1(char x), and class1(float x). Which of the above constructors will be called when the following statement is executed : class1 obj; ?

Choose one answer. A. None of the constructor is called. B. class1(float x) C. class1(int x) D. class1() 22. Consider the following code snippet: using System; namespace square_num { class Box { double width; double height; double depth; Box() { Console.WriteLine("Constructing Box");//display on this width = 10; height = 10; depth = 10; } public double Calculate_Vol() {

return width * height * depth;//we r returning nothing } static void Main(string[] args) { Box b = new Box(); Console.ReadLine(); } } } Identify the output of the preceding code.

Choose one answer. A. Constructing Box B. Volume is 1000.0 Constructing Box C. Compilation error D. Constructing Box Volume is 1000.0 23. Predict the output of the following code snippet: public static void Main() { int i = 0; FileStream fs = new FileStream("C:\\Preeti\\Myfile.txt", FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs); sr.BaseStream.Seek(0, SeekOrigin.Begin); FileStream fs1 = new FileStream("C:\\Preeti\\Myfile1.txt", FileMode.CreateNew , FileAccess.Write ); StreamWriter sw = new StreamWriter(fs1); while ((i=sr.Read()) != -1) { sw.Write(Convert.ToChar(i+1)); } sr.Close(); sw.Close(); }

Choose one answer. A. It is reading the source file character by character and writing alternate characters in the target file. B. It is reading the source file character by character and writing each character by incrementing its ascii value by 1 in the target file. C. It is reading the source file character by character and writing each character in the target file. D. It is reading the source file character by character and writing each character twice in the target file. 24. public void commonMemberArray() { int[] numbersArr1 = { 0, 2, 4, 5, 6, 8, 9 }; int[] numbersArr2 = { 1, 3, 5, 7, 8 }; var commonNumbers = numbersArr1.Intersect(numbersArr2); Console.WriteLine("Common numbers shared by both arrays:"); foreach (var n in commonNumbers) { Console.WriteLine( n ); } } Predict the output of the above code

Choose one answer. A. Common numbers shared by both arrays: 8 9 B. Common numbers shared by both arrays: 0 1 C. Common numbers shared by both arrays: 5 8 D. Will generate error 25. Marks: 1/1 Can you declare an override method to be static if the original method is not static Choose one answer. A. Yes B. No

You might also like