What is the difference between the members in private visibility

Subject

Computer and Communication Technology

Class

CBSE Class 12

Pre Boards

Practice to excel and get familiar with the paper pattern and the type of questions. Check you answers with answer keys provided.

Sample Papers

Download the PDF Sample Papers Free for off line practice and view the Solutions online.
Advertisement

 Multiple Choice QuestionsMultiple Choice Questions

1.

What out of the following, will you use to have an audio-visual chat with an expert sitting in a faraway place to fix-up a technical issue?

  • VoIP

  • email

  • FTP

204 Views

2.

Which out of the following comes under Cyber Crime?

  • Operating someone’s internet banking account, without his knowledge.

  • Stealing a keyboard from someone’s computer.

  • Working on someone’s computer with his/her permission.

82 Views

 Multiple Choice QuestionsShort Answer Type

3.

Give the difference between the Type Casting and automatic Type Conversion. Also, give a suitable C++ code to illustrate both.

86 Views

4.

Which C++ header file(s) are essentially required to be included to run/execute the following C++ source code (Note: Do not include any header file, which is/are not required);

Void main()
{
	char TEXT[] = 'SomeThing';
	cout<<'Remaining SMS Chars:'
	<<160-strlen(TEXT)<< endl;
}

72 Views

Advertisement
5.

Rewrite the following program after removing the syntactical error(s) (if any). Underlie each correction.

#include<iostream.h>
Class Item
{
	long IId,Qty;
public:
	void Purchase
	{
		cin>>IId>>Qty;
	}
}	void Sale()
{
	cout<<setw(5)<<IId<<'Old:'<<Qty<<endl;
	cout<<'New:'<<--Qty<< endl;
}
void main()
{
	Item I;
	Purchase();
	I.Sale();
	I.Sale(0)
}

76 Views

6.

Find the output of the following program:

#include<iostream.h>
class METRO
{
	int Mno, TripNo,PassengerCount;
public:
	METRO (int Tmno=1)
	{
		Mno=Tmno;TripNo=0;PassengerCount=0;
	}
	void Trip(int PC=20)
	{
		TripNo++;PassengerCount+=PC;
	}
	void StatusShow()
	{
		cout<<Mno<<':'<<TripNo<<':'<<PassengerCount<<endl;
	}
};
	void main()
	{
		METRO M(5),T;
		M.Trip();
		T.Trip(50);
		M.StatusShow();
		M.Trip(30);
		T.StatusShow();
		M.StatusShow();
	
	}

113 Views

7.

Find the output of the following program:

#include<iostream.h>
#include<c.type.h>
typeof char Str80[80];
void main()
{
	char*Notes;
	Str80 Str='vR2GooD':
	int L = 6;
	Notes =Str;
	while(L>=3)
	{
		Str[L]=(isupper(Str[L])?tolower(Str[L]):toupper(Str[L]));
		cout<<Notes<<endl;
		L--;
		Notes++;
	}
}

80 Views

8.

Observe the following program and find out, which output(s) out of(i) to(iv) will not be expected from the program? What will be the minimum and the maximum value assigned to the variable chance?

#include<iostream.h>
#include<stdlib.h>
void main( )
{
	randomize( );
	int Arr[]={9,6},N;
	int Chance=random(2)+10;
	for (int C=0;C<2;C++)
	{
		N=random(2);
		cout<<Arr[N]+Chance<<'#';
	}
}

(i) 9#6#   (ii) 19#17#  (iii) 19#16#   (iv) 20#16#

103 Views

Advertisement
Advertisement

9.

What is the difference between the members in private visibility mode and the members in protected visibility mode inside a class? Also, give a suitable C++ code to illustrate both.


 

Private Public
Private members of a class are accessible only from within other members of the same class or from their friends. Protected members are accessible from members of their same class and from their friends, but also from members of their derived classes.
#include <iostream> 
class Example
{
public:
	int a;
	int add(); private:
	int b;
};
	int Example::add()
{
	return a+b ;
}
void main( )
{
	Example ex;
	ex.a = 10; // OK: because a is public
	ex.b = 20; // Error: because b is private
	int sum=ex.add(); // local variable
	cout << 'Sum of a + b : ' <<
}
Output: Error due to access of
private member
#include <iostream.h> 
class ExBase
{
	protected: int i, j;
};

class ExDerived : public ExBase { public:
	void show()
	{
		i=35; j=45;
		//both i & j are accessible here cout<<'Value of i '<<i; count<<'Value of j '<<j;
	}
};
void main()
{
	ExDerived exd; exd.show();//both I and j are not accessible exd.i=50;
	exd.j=60;
}
88 Views

Advertisement
10.

Answer the question (i) and (ii) after going through the following class :

class Travel
{
	int PlaceCode; char Place[20]; float Charges; public:
Travel( )	//Function 1
{
	PlaceCode=1;strcpy(Place,'DELHI');Charges=1000;
}
void TravelPlan(float C )	// Function 2
{
	cout<<PlaceCode<<':'<<Place<<':'<<Charges<<endl;
}
~Travel( )	// Function 3
{
	cout<<'Travel Plan Cancelled'<<endl;
}
Travel(int PC,char p[],float C)	// Function 4
{
	PlaceCode=PC;strcpy(Place,P);Charges=c;
}

(i) In Object Oriented Programming, what are Function 1 and Function 4 combined together referred as?

(ii) In Object Oriented Programming, which concept is illustrated by Function 3? When is this function called/invoked?

82 Views

Advertisement