Physics Answerss
Physics Answerss
Computer Science
Important Questions with Solutions
Question 1:
Write any four important characteristics of object oriented programming. Give example of any
one of the characteristics using C++. All India 2016
Answer:
Four important characteristics of object oriented programming are as follows:
Example of Inheritance
Class Rectangle
{
::::
};
class Area : public Rectangle
{
::::
};
Question 2:
Explain data hiding with an example. All India 2014C
Answer:
Data hiding is a property, where internal data structure of an object is hidden from the outside
world. Data hiding helps to secure the data. It is implemented with private and protected
keywords. ,
e.g.
class Item
{
private:
int item_no;
float item_cost;
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
2
public:
void getdata();
void putdata();
};
Here, in this example variables item_no and item_cost are hidden, i.e. cannot be directly
accessed from outside the class Item.
Question 3:
What is function overloading? Give an example in C++ to illustrate function overloading.
All India 2014,2009
or
What do you understand by function overloading? Give an example illustrating its use in a C++
program. All India 2009
Answer:
When several functions have same name but performing different tasks, then it is known as
function overloading. The definitions of these functions are differentiable by the number or
types of their arguments.
e.g.
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
3
#include<iostream.h>
void Print() //Function[I]
{
for(int K=1; K<=60; K++)
cout<<"-";
cout<<endl;
}
void Print(int N) //Function[II]
{
for(int K=1; K<=N; K++)
cout<<"*";
cout<<endl;
}
void Print(int A, int B)//Function[III]
}
for(int K=1; K<=B; K++)
cout<<A*K;
cout<<endl;
}
void Print(char T, int N)//Function[IV]
{
for(int K=l; K<=N; K++)
cout<<T;
cout<<endl;
}
void main!)
{
int U=9, V=4, W=3;
char C= '@';
Print(C, V);
Print(U, W);
}
Answer:
Feature of C++→ Function overloading The output will be:
@@@@
91827
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
4
Question 5:
Write the output of the following C++ code. Also, write the name of feature of Object Oriented
Programming used in the following program jointly illustrated by the functions [I] to [IV]: All
India 2011
#include<iostream.h>
void Lined //Function[I]
{
for(int L=1;L<=80;L++)
cout<<"-";
cout<<endl;
}
void Line(int N) //Function[II]
{
for(int L=1;L<=N;L++)
cout«"*";
cout<<endl:
}
void Line(char C,int N) //Function[III]
{
for(int L=1:L<=N:L++)
cout<<C;
cout<<endl:
}
void Line(int M, int N)//Function[IV]
{
for(int L=1:L<N;L++)
cout<<M*L;
cout<<endl;
}
void main()
{
int A=9, B=4, C=3;
char K=’#':
Line (K,B);
Line (A,C);
Answer:
Feature of C ++ Function overloading Output will be :
####
91827
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
5
Question 6:
What do you understand by Data Encapsulation and Data Hiding? Also, give an example in C++
to illustrate
both. All India 2010
Answer:
Data Encapsulation
The wrapping up of data (member variables) and functions into a single unit is known as data
encapsulation. Encapsulation is implemented in C ++ with the help of classes.
Data Hiding
When member data and member function are binded into a single unit then the data is not
accessible to the outside world and only those functions, which are wrapped in that class can
access it. Data hiding is implemented in C+ + with the help of private and protected keywords.
Question 7:
What do you understand by polymorphism? Give an example illustrating its use in a C++
program. Delhi 2010
Answer:
Polymorphism means processing of data or messages in more than one form. C ++ implements
polymoiphism through overloaded functions and overloaded operators,
e.g.
float compute(float a)
{
return a*a;
}
float computer float a,float b)
{
return(a*b);
}
Question 8:
How are abstraction and encapsulation interrelated? Delhi 2009
Answer:
Abstraction refers to the representation of only the essential features of the real-world object
in the program. This process does not include the background details and explanations. This
concept of abstraction is used in classes whereas, data encapsulation is the most significant
characteristic of the class. By this term, we mean the wrapping up of data and functions which
operate on the data, into a single unit called the class. This encapsulation prevents free access
to the data within an object.
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
6
Question 9:
What is event driven programming?
Answer:
In event driven programming, the user indicates the order of program execution not the
programmer. Instead of, the program ‘driving’ the user ‘drives’ the program. Programming, in
which the code that responds to the event is called event driven programming.
Question 10:
What is the significance of classes in OOPs?
Answer:
The classes are the manufacturing units of the objects of their type, i.e. it is the class that can
be used to create an object. Classes are user defined data types and behave like the built-in
types of a programming language. Classes are the basic building blocks of object oriented
programming.
Question 11:
What are the advantages of object oriented programming over procedural oriented
programming?
Answer:
Advantages of Object Oriented Programming (OOP) over Procedural Oriented Programming
(POP)
In OOP, program is divided into parts called In POP, program is divided into small parts
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
7
OOP provides data hiding that provides more POP does not have any proper way for data
C++, Java, VB.NET, C, .NET, etc. are the C, VB, FORTRAN, Pascal etc are the examples
Question 12:
Encapsulation is one of the major properties of OOP. How is it implemented in C++? HOTS
Or
Define the term data encapsulation in terms of object oriented programming. Give a suitable
example using a C++ code to illustrate the same.
Answer:
The wrapping up of data and functions into a single unit is called data encapsulation. That single
unit is known as class.
e.g.
class person
{
char name[30];
int age;
public:
void getdata(void);
void display(void);
};
The above program implements data hiding as data can’t be accessed directly from outside.
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
8
Question 13:
What is operator overloading? Explain with example.
Answer:
The process of making an operator to exhibit or show different behaviour in different situations
is called as operator overloading.
e.g. consider the operation of (+) operator. Operation is sum, if operands are integer type and
the operation is concatenation, if operands are strings.
Question 14:
Rewrite the following program after removing the syntactical errors (if any). Underline each
correction. Delhi 2012
#include<iostream.h>
class Book
{
long Bld.Qty;
public:
void Purchase()
{
cin>>BId<<Qty;
}
void Sale
{
cout<<setw(5)<<BId<<"o1d:”<<Qty<<endl;
cout<<"New:"<<—Qty<<endl;
}
};
void main()
{
Book B;
B.Purchase();
Sale();
B.Sale();
}
Аnswers:
#include<iostream.h>
#include<iomanip.h>
class Book
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
9
{
long Bid, Qty;
pub!ic:
void Purchase()
{
cin>>BId>>Qty;
}
void Sale()
{
cout<<setw(5)<<BId<<"o1d:"<<Qty<<endl;
cout<<"New:"<<--Qty<<endl;
}
};
void main()
{
Book B;
B.Purchase();
B.Sale();
B.Sale();
}
Question 15:
Rewrite the following program after removing the syntactical errors (if any). Underline each
correction. Delhi 2012
#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;
}
};
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
10
void main()
{
Item I;
Purchase():
I.Sale();
I.Sale();
}
Аnswers:
#include<iostream.h>
#include<iomanip.h>
class Item
{
long lid,Qty;
public:
void Purchase()
{
cin>>IId>>Qty;
}
void Sale()
{
cout<<setw(5)<<IId<<"01d:"<<Qty<<endl;
cout<<"New:"<<--Qty<<endl;
}
};
void main()
{
Item I;
I.Purchase();
I.Sale();
I.Sale();
}
Question 16:
Define a class SUPPLY in C++ with following description: All Indio 2012
Private members
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
11
Sticker FoodType
GREEN Vegetarian
YELLOW Contains Egg
RED Non-Vegetarian
Public members
A function FoodIn( ) to allow user to enter values for Code, FoodName, Sticker
and call function GetType( ) to assign respective FoodType.
A function FoodOut( ) to allow user to view the content of all the data members.
Аnswer:
class SUPPLY
{
int Code;
char FoodName[30],Sticker[30];
char FoodType[20];
void GetType()
{
if(strcmp(Sticker, "GREEN”)==0)
strcpy(FoodType,"Vegetarian" );
else if(strcmp(Sticker,"YELLOW")==0)
strcpy(FoodType,"Contains Egg");
else if(strcmp(Sticker,"RED")==0)
strcpy(FoodType,"Non -Vegeta rian");
}
public:
void FoodIn()
{
cout<<"Enter Code, FoodName, Sticker";
cin>>Code;
gets(FoodName);
gets(Sticker);
GetType();
}
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
12
void Food0ut()
{
cout<<"Code,FoodName,Sticker,FoodType are";
cout<<Code<<FoodName<<Sticker<<FoodType;
}
};
Question 17:
Define a class HOTEL in C++ with the following specification: All IndiA 2009
Private members
Public members
Checkin( ) Function to enter the content Rno, Name, Tariff and NOD
Checkout( ) Function to display Rno, Name, Tariff, NOD and Amount (amount to
be displayed by calling function
CALC( ))
Аnswer:
class HOTEL
{
int Rno,NOD;
char Name[30];
float Tariff;
float CALC()
{
float temp=NOD*Tariff;
if(temp>10000)
return(1.05*temp);
return temp;
}
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
13
public:
void Checkin()
{
cout«"Enter the room number:";
cin>>Rno;
cout<<"Enter the customer name:";
gets(Name);
cout<<"Enter the room charges per day";
cin>>Tariff ;
cout<<"Enter number of days stayed by customer:";
cin>>NOD;
}
void Checkout()
{
cout<<"Room number:"<<Rno;
cout<<"Customer Name:";
puts(Name);
cout<<"Charges per day:"<<Tariff;
cout<<"Number of days stayed by customer:"<<NOD;
cout<<"Total charges of customer:"<<CALC();
}
};
Question 18:
Find the output of the following program: All India 2012
#include<iostream.h>
#include<conio.h>
#include<ctype.h>
typedef char Str80[80];
void main()
{
char *Notes;
Str80 Str="vR.zGooD";
int L=6;
Notes = Str;
while(L>=3)
{
Str[L]=isupper(Str[L])?
tolower(Str[L]);
toupper(Str[L]);
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
14
cout<<Notes<<endl;
L--;
Notes++;
getch();
}
}
Аnswer:
Output of the given program will be
vR.zGoOd
R.zGOOD
.zgOOD
ZgOOD
Question 19:
Find the output of the following program: Delhi 2012
#include<iostream.h>
#include<conio.h>
#include<ctype.h>
typedef char Txt80[80];
void main()
{
char *PText;
Txt80 Txt="Ur2GReAt";
int N=6;
PText=Txt:
while(N>=3)
{
Txt[N]=isupper(Txt[N])?
tolower(Txt[N]);
toupper(Txt[N]);
cout<<PText<<endl;
N--;
PText++;
}
}
Аnswer:
Output of the given program will be
Ur2GReat
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
15
r2GREat
2GrEat
great
Question 20:
Give the output of the following program segment. (Assume, all required header files are
included in the program.)
void main()
{
char *s="GOODLUCK";
for(int x=strlen(s)-1;x>=0;x--)
{
for(int y=0;y<=x;y++)
cout<<s[y];
cout<<endl;
}
}
Аnswer:
Output of the given program will be
GOODLUCK
G00DLUC
G00DLU
GOODL
GOOD
GOO
GO
G
Question 21:
Find the output of the following program. All India 2009
#include<iostream.h>
#include<conio.h>
void main()
{
int A[] = {10, 15, 20, 25. 30};
int *p = A;
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
16
whi1e(*p<30)
{
if(*p%3!= 0)
*p = *p+2;
else
*p = *p+1;
P++;
}
for(int J=0;J<=4;J++)
{
cout<<A[J]<<"*";
if(J*3 == 0)
cout<<endl;
}
cout<<A[4]*3<<endl;
}
Аnswer:
Output of the given program will be
12*
16*22*27*
30*90
Question 22: DOJ refers to Date of Joining and DOB refers to Date of Birth of workers.
(i) To display WNO, NAME,, GENDER from the table WORKER in descending order of WNO.
(ii) To display the NAME of all the FEMALE workers from the table WORKER.
(iii) To display the WNO and NAME of those workers from the table WORKER, who are born
between ‘1987-01-01’ and ‘1991-12-01’.
(iv) To count and display MALE workers who have joined after ‘1986-01-01’.
(i) SELECT WNO, NAME, GENDER FROM WORKER ORDER BY WNO DESC;
(ii) SELECT NAME FROM WORKER WHERE GENDER = "FEMALE";
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
17
(iii) SELECT WNO, NAME FROM WORKER WHERE DOB BETWEEN '1987-01-01' AND '1991-12-
01';
(iv) SELECT COUNT(*) FROM WORKER WHERE GENDER = "MALE" AND DOJ > '1986-01-01';
Question 23:
Answer the questions (a) and (b) on the basis of the following tables STORE and ITEM. Delhi
2014
(i) To display the name of streams in alphabetical order from table STREAM.
(ii) To display the number of students whose POINTS are more than 5.
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
18
(ii) (iii) To update GRADE to ‘A’ for all those students who are getting more than 8 as
POINTS.
(iv) ARTS+MATHS stream is no more available. Make necessary change in table fjTREAM.
SET-B
Question 1.
Which tags of HTML are used to
(i) Change the font in a page
(ii) Add a row in a table? (Delhi 2014)
Answer:
(i) < FONT > tag is used to change font in a page.
(ii) <TR> tag is used to add a row in a table.
Question 2.
Which tags/attributes of HTML are used to
(i) Insert the picture in the web page.
(ii) Insert an empty line on the web page. (All India 2014)
Answer:
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
19
Question 3.
Name two tags that are present in every HTML code. (All India 2014C)
Answer:
Two tags that are present in every HTML code:
(i) <HTML>
(ii) <BODY>
Question 4.
Write the name of HTML tag used to include an image in an HTML web page. (Delhi 2012)
Answer:
To include an image in HTML web page the < I MG src = “pathname”> tag is used. Here, in place
of a pathname, we have to specify the location on the computer, where the image is stored.
Question 5.
Write HTML code for the following:
To provide a hyperlink to a website (HOTS; Delhi 2012)
http://WWW.w3schoo1.com
Answer:
To provide a hyperlink to a website http://www.w3school.com, we have to write following
statement:
<A href=“http://www.w3school.com”>
Click Here </A>
Question 6.
Write the name of HTML tag used to include numbered list in a HTML web page. (All India 2012)
Answer:
To include a numbered list in a HTML web page, we have to use the <OL> tag.
Question 7.
Write HTML code for the following:
To provide hyperlink to a website (HOTS; All India 2012)
http://www.cbse.nic.in
Answer:
To provide hyperlink to a website http://www.cbse.nic.in, we have to use the following tag:
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
20
<A href=“http://www.cbse.nic.in”>
Click Here</A>
Question 8.
Which HTML tags are used for making a table and adding rows in an HTML document? (Delhi
2011; All India 2011)
Answer:
To make a table, the <TABLE > tag is used. We can use <TR> tag to define and insert a row into
the table and to specify the data to be entered in the table we use the < TD > tag.
Question 9.
How is <OL> tag different from <UL> tag of HTML? (Delhi 2011; All India 2011)
Answer:
The <UL> tag in HTML is used to define an unordered or bulleted list, where the list items are
displayed using bullets without numbering. Whereas, <OL> tag is used to define the ordered
list, where the list items are displayed by using the numbers in different number formats.
Question 10.
Java is writing an HTML code. How can she see, how the code would look as a web page? (Delhi
2011C)
Answer:
She have to save the HTML code file created in a text editor with .htm or .html extension.
Thereafter she needs to open the file in a web browser like Internet Explorer.
Question 11.
What is wrong in the following HTML code: (HOTS; Delhi 2011C)
Question 13.
What is an HTML tag?
Answer:
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
21
Tags have a simple structure. They begin with a ” < ” and end with a ” > “. Between the’ < >”
angular bracket the tag name and may be some attributes are written, depending upon the tag.
SET-C
Question 1:
Find and write the output of the following C++ program code: All India 2016 NOTE Assume all
required header files are already being included in the program.
class Share
{
long int Code;
float Rate;
int DD;
public:
Share(){Code=1000;Rate=100;DD=1;}
void GetCode(long int C, float R)
{
Code=C;
Rate=R;
}
void Update(int Change, int D)
{
Rate+=Change;
DD=D;
}
void Status()
{
cout<<"Date: "<<DD<<endl;
cout<<Code<<"#”<<Rate<<endl;
};
void main()
{
Share S,T,U;
S.GetCode(1324,350);
T.GetCode(1435,250);
S.Update(50,28);
U.Update(-25,26);
S.Status();
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
22
T.Status();
U.Status();
}
Аnswer:
Output of the given program would be:
Date: 28
1324#400
Date: 1
1435#250
Date: 26
1000#75
Question 2:
Differentiate between Constructor and Destructor functions giving suitable example using a
class in C++. When does each of them execute? Delhi 2016
or
Write any two differences between constructor and destructor. Write the function header for
constructor and destructor of a class Member. Delhi 2013
or
Differentiate between constructor and destructor functions in a class. Give a suitable example
in C+ + to illustrate the difference. Delhi 2012c
or
Differentiate between constructor and destructor function with respect to object oriented
programming. All India 2011
Аnswer:
Constructor Destructor
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
23
e.g.
class Member
{
public:
Member() //Constructor
{
cout<<"I am a constructor of Member class";
}
~Member() //Destructor
{
cout<<"I am destructor of Member class";
}
};
Question 3:
What is the difference between local variable and global variable? Also, give a suitable C++ code
to illustrate both. Delhi 2011
Аnswer:
A variable which is declared within the body of a function and accessible only within the
function is known as local variable.
A variable which is declared outside any function and accessible to all functions in a program is
known as global variable.
To illustrate this, below is given programming example:
#include<iostream.h>
float area; //Global variable
void cirarea()
{
float r; //Local variable
cin>>r
area=3.14*r*r;
cout<<area;
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
24
}
void rectarea()
{
float l,b; //Local variables
cin>>l>>b;
area=l*b;
cout<<area;
}
void main()
{
cirarea();
rectarea();
}
Question 4:
Name the header file(s), which are essentially required to run the following program segment.
void main()
}
char A='K',B;
if(islower(A))
B=toupper(A);
else
B='*';
cout<<A<<"turned to"<<B<<endl:
} Delhi 2013C
Аnswer:
<iostream.h>→cout,cin
<ctype.h>→ islower( ); i supper( )
Question 5:
Write the names of the header files to which the following belong:
1. puts( )
2. sin( ) Delhi2009
Аnswer:
puts( )→<stdio.h>
sin( )→<math.h>
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
25
Question 6:
Write the names of the header files to which the following belong:
1. setw( )
2. sart( ) All India 2009
Аnswer:
setw( )→<iomanip.h>
sqrt( )→<math.h>
Question 7:
Write the names of the header files to which the following belong:
1. puts( )
2. randomizer( ) Delhi2009c
Аnswer:
puts( )→<stdio.h>
randomize( )→<stdlib.h>
Question 8:
Find the output of the following program: All India 2014C
#include<iostream.h>
void in(int x, int y, int &z)
}
x+=y;
y--;
z*=(x-y);
}
void out(int z, int y, int &x)
{
x*=y;
y ++;
z/=(x+y);
}
void main()
{
int a=20, b=30, c=10;
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
26
out(a,c,b);
cout<<a<<"#"<<b<<"#"<<c<=><"#"<<endl:
in(b,c,a):
cout<<a<<"@"<<b<<''@"<<c=><<"#"<<endl;
out(a,b,c);
cout<<a<<"$"<<b<<"$"<<c<<”=>$"<<endl;
}
Аnswer:
Output
20#300#10#
602 0@ 3 0 0@10@
6020$300$3000$
Question 9:
Study the following program and select the possible output from it
#include<iostream.h>
#include<stdlib.h>
const int LIMIT=4;
void main()
{
randomize();
int Points;
Points=100+random(LIMIT);
for(int P=Points';P>=100;P--)
cout<<P<<"#";
cout<<endl;
}
(i) 103 # 102 # 101 # 100 #
(ii) 100 # 101 # 102 # 103 #
(iii) 100 # 101 # 102 # 103 # 104 #
(iv) 104 # 103 # 102 # 101 # 100 # Delhi 2009
Аnswers:
(i) 103 # 102 # 101 # 100#
Question 10:
Study the following program and select the possible output from it
#include<iostream.h>
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
27
#include<stdlib.h>
const int MAX=3;
void main()
{
randomize();
int Number;
Number=50+random(MAX);
for(int P=Number;P>=50;P--)
cout<<P<<"#”;
cout<<endl;
}
(i) 53 # 52 # 51 # 50
(ii) 50 # 51 # 52 #
(iii) 50 # 51 #
(iv) 51 # 50 # All India 2009
Аnswers:
(iv) 51 # 50 #
Question 11:
Find syntax error(s), if any, in the following program: (Assuming all desired header file(s) are
already included)
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/
28
S[L]="\0" ;
cout<<S<<end l ;
}
All Rights Reserved © Manish Verma, For more Notes visit https://manishvermaofficial.com/