Q.1.
What is the process by which we can control what parts of a program can access the members of a class?
Q.2.
Which of these base class are accessible to the derived class members?
Q.3.
Which of these is used as default for a member of a class if no access specifier is used for it?
Q.4.
Which among these access specifiers should be used for main() method?
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); } }
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(); }}
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(); }}
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(); }}
Q.9.
Which of these access specifiers must be used for class so that it can be inherited by another subclass?
Q.10.
Which of the following statements are incorrect?
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(); } }
Q.12.
Accessibility modifiers defined in a class are?