Question
class access
{
public int x;
private int y;
public void cal(int a, int b)
{
x = a + 1;
y = b;
}
public void print()
{
Console.WriteLine(" " + y);
}
}
class Program
{
static void Main(string[] args)
{
access obj = new access();
obj.cal(2, 3);
Console.WriteLine(obj.x);
obj.print();
Console.ReadLine();
}
}
a.
2 3
b.
3 3
c.
Run time error
d.
Compile time error
Posted under C# programming
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What will be the output of the given code snippet?
Similar Questions
Discover Related MCQs
Q. Which of these base class are accessible to the derived class members?
View solution
Q. What is the process by which we can control what parts of a program can access the members of a class?
View solution
Q. Which of these is used as default for a member of a class if no access specifier is used for it?
View solution
Q. Which among these access specifiers should be used for main() method?
View solution
Q. What is the return type of destructor ?
View solution
Q. Select wrong statement about destructor in C#?
View solution
Q. Operator used to free the memory when memory is allocated ?
View solution
Q. Name a method which has the same name as that of class and which is used to destroy objects also called automatically when application is finally on process of being getting terminated.
View solution
Q. The method called by clients of a class to explicitly release any resources like network,connection,open files etc.When the object is no longer required?
View solution
Q. Which operator among the following signifies the destructor operator?
View solution
Q. Which method has the same name as that of its class?
View solution
Q. What is the return type of constructors?
View solution
Q. Which of the following statements is correct about constructors in C#.NET?
View solution
Q. Can the method add() be overloaded in the following ways in C#?
public int add() { }
public float add(){ }
View solution
Q. Which among the following is the correct statement :
Constructors are used to
View solution
Q. Correct statement about constructors in C#.NET is ?
View solution
Q. Number of constructors a class can define is ?
View solution
Q. Which return statement correctly returns the output:
View solution
Q. How many values does a function return?
View solution
Q. When a function fun() is to receive an int, a single & a double and it is to return a decimal, then the correct way of defining this function is?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond C# programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!