My Report

Object Oriented Programming Mock Test 3


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement
 10%

Question 1 of 10

1. What will be the output of the following code (all header files and required things are included)?

class A
{
	int marks;
	protected : A(int x)
	{ 
		marks=x; 
	}
	public : A()
	{ 
		marks=100; 
	}
}
class B
{
	A a;
	A b=100;
};
main()
{
	A a, b=100;
	B c;
}

Question 1 of 10

Question 2 of 10

2. Which among the following is true for public class?

Question 2 of 10

Question 3 of 10

3. What is the output of the following code?

package pack1;
class A
{
	public A()
	{ 
		System.out.print(“object created”); 
	}   
}
package pack2;
import pack1.*;
class B
{
	A a=new A();
}

Question 3 of 10

Question 4 of 10

4. Which member function doesn’t require any return type?

Question 4 of 10

Question 5 of 10

5. The static member functions can only use ________

Question 5 of 10

Question 6 of 10

6. How to access members of the class inside a member function?

Question 6 of 10

Question 7 of 10

7. Which among the following is correct for the code given?

class A
{
    private: int marks;
    A()
    { 
    }
    Public : disp()
    { 
          cout<< marks; 
     }
};
class B: public A
{
}
B b;

Question 7 of 10

Question 8 of 10

8. Which specifier can be used to inherit protected members as protected in subclass but public as public in subclass?

Question 8 of 10

Question 9 of 10

9. Which option is false for the following code?

class A
{
	private : int sum(int x, int y)
	{ 
		return x+y; 
	}
	public: A()
	{  
	}
	A(int x, int y)
	{ 
		cout<<sum(x,y);  
	}
};

Question 9 of 10

Question 10 of 10

10. Which among the following can be used for outermost class access specifier in java?

Question 10 of 10


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.