Q.1
What is the process by which we can control what parts of a program can access the members of a class?
  • a) Polymorphism
  • b) Abstraction
  • c) Encapsulation
  • d) Recursion
Q.2
Which of these base class are accessible to the derived class members?
  • a) static
  • b) protected
  • c) private
  • d) shared
Q.3
Which of these is used as default for a member of a class if no access specifier is used for it?
  • a) private
  • b) public
  • c) protected internal
  • d) protected
Q.4
Which among these access specifiers should be used for main() method?
  • a) private
  • b) public
  • c) protected
  • d) none of the mentioned
Q.5
What will be the output of the following C# code snippet? class access { public int x; private int y; public void cal(int a, int b) { x = a + y = b; } } class Program { static void Main(string[] args) { access obj = new access(); obj.cal(3); Console.WriteLine(obj.x + " " + obj.y); } }
  • a) 3 3
  • b) 2 3
  • c) Run time error
  • d) Compile time error
Q.6
What will be the output of the following C# code snippet? class access{ public int x; private int y; public void cal(int a, int b) { x = a + y = b; } public void print() { Console.WriteLine(" " + y); } } class Program{ static void Main(string[] args) { access obj = new access(); obj.cal(3); Console.WriteLine(obj.x); obj.print(); Console.ReadLine(); }}
  • a) 2 3
  • b) 3 3
  • c) Run time error
  • d) Compile time error
Q.7
What will be the output of the following C# code snippet? class sum { public int x; public int y; public int add (int a, int b) { x = a + b; y = x + b; return }} class Program{ static void Main(string[] args) { sum obj1 = new sum(); sum obj2 = new sum(); int a = obj1.add(a, a + 1); obj2.add(a); Console.WriteLine(obj1.x + " " + obj2.y); Console.ReadLine(); }}
  • a) 6, 9
  • b) 5, 9
  • c) 9, 10
  • d) 3, 2
Q.8
What will be the output of the following C# code snippet? class static_out{ public static int x; public static int y; public int add(int a, int b) { x = a + b; y = x + b; return }} class Program{ static void Main(string[] args) { static_out obj1 = new static_out(); static_out obj2 = new static_out(); int a = obj1.add(a, a + 1); obj2.add(a); Console.WriteLine(static_out.x + " " + static_out.y ); Console.ReadLine(); }}
  • a) 7 7
  • b) 6 6
  • c) 7 9
  • d) 9 7
Q.9
Which of these access specifiers must be used for class so that it can be inherited by another subclass?
  • a) public
  • b) private
  • c) both public & private
  • d) none of the mentioned
Q.10
Which of the following statements are incorrect?
  • a) public members of class can be accessed by any code in the program
  • b) private members of class can only be accessed by other members of the class
  • c) private members of class can be inherited by a subclass, and become protected members in subclass
  • d) protected members of a class can be inherited by a subclass, and become private members of the subclass
Q.11
What will be the output of the following C# code snippet? class test { public int a; public int b; public test(int i, int j) { a = i; b = j; } public void meth(test o) { o.a *= o.b /= } } class Program { static void Main(string[] args) { test obj = new test(20); obj.meth(obj); Console.WriteLine(obj.a + " " + obj.b); Console.ReadLine(); } }
  • a) 20, 40
  • b) 40, 20
  • c) 20, 10
  • d) 10, 20
Q.12
Accessibility modifiers defined in a class are?
  • a) public, private, protected
  • b) public, internal, protected internal
  • c) public, private, internal, protected internal
  • d) public, private, protected, internal, protected internal
0 h : 0 m : 1 s