Sei sulla pagina 1di 11

Computer Science CBSE XII Viva Questions

CHAPTER 1: Review of C++

1. What are tokens, identifiers, literals. Pl learn the naming conventions of these.
· Tokens- Smallest individual unit. Following are the tokens
· Keyword-Reserve word having special meaning the language and can’t be used as
o identifier.
· Identifiers-Names given to any variable, function, class, union etc. Naming
convention (rule) for writing identifier is as under:
o First letter of identifier is always alphabet.
o Reserve word cannot be taken as identifier name.
o No special character in the name of identifier except under score sign ‘_’.
· Literals-Value of specific data type assign to a variable or constant. Four type of
Literals: i) Integer Literal i.e int x =10 ii) Floating point Literal i.e float x=123.45
§ iii)Character Literal i.e char x= ‘a’, enclosed in single quotes and single character
only. iv) String Literal i.e cout<< “Welcome” , anything enclosed in double
quotes
· Operator – performs some action on data o Arithmetic(+,-
,*,/,%) o Assignment operator (=) o Increment / Decrement (++, --
) o Relational/comparison (<,>,<=,>=,==,!=). o Logical(AND(&&),OR(||),NOT(!).
o Conditional (? :)

2. Name simple, compound and user defined data types.


· Fundamental type/simple : Which are not composed any other data type i.e. int,
char, float and void
· Derived data type /compound: Which are made up of fundamental data type i.e
array, function, class etc
· User defined: they are tailor made data types created by the user eg structures
and classes

3. What are macros? How they are implemented in C++?


Macros: These are very simple inline functions which are written before
main().These are on line functions returning very simple calculations eg area of
square circle etc.When the compiler encounter a function call the function call is
replaced by the program code. This ensures faster processing by removing the
overhead required for transferring control to function definition.
eg

#include <iostream.h>
#define area_square(s) s*s
void main()
{ cout<<"Area of square: "<<area_square(4);
}
output:
Area of square: 16

4. What is typedef? How to define another name for string, int, float or char datatypes?
Used to define new data type name.
e.g. typedef char Str80[80];
Str80 str;
So the new name for char data type here will be Str80. str is a variable of Str80
having size as 80 char.
eg 2. typedef int age;
age x;
Here Age is the new name for int data type . x is a variable having age data type.

5. How can you call a variable by two names?


By using alias name as in reference variables. Eg When we pass a variable by reference
in a function, the same variable has two names, one in the calling function and the
other in the function definition.
Eg
void func1( int & marks)
{ if(marks>90) alias name
cout<<”V.Good”;
else
Cout<<”Good”;
}
void main()
{ int m;
cout<<”Enter marks”;
cin>> m;
func1(m);
} actual name

6. What are reference variables?


7. References:
A reference is an alternative name for an object or variable A reference variable
provides an alias for a previously defined variable. A reference declaration consists
of base type , an & (ampersand), a reference variable name equated to a variable
name .the general syntax form of declaring a reference variable is as follows.
Type & ref_variable = variable_name;
Where type is any valid C++ datatype, ref_variable is the name of reference variable
that will point to variable denoted by variable_name.
e.g int a= 10;
int &b= a;
then the value of a is 10 and the value of b is also 10;

8. Diff between ‘’h’’ & ‘h’


Here “h” is a string having size 2 bytes. ‘h’ is a character constant with size 1 byute.
9. Diff between getch ( ) & getche( )
getch() and getche() both accept a single character from inout stream, getche also
shows the character on the screen( e stands for echo).
10. Diff between toupper( ) & isupper( )
toupper()-converts given character to uppercase
isupper()- returns true if the character is uppercase else returns false.
11. Diff between if (i=2) & if(i= =2)
(i=2) : this assigns value 2 to i
if(i= =2): this checks whether the value of I is 2 or not and returns true or false
accordingly.
12. use of # include
#include is the preprocessor directive used in C++ programs. This statement tells
the
compiler to include the specified file into the program. This line is compiled by the
processor
before the compilation of the program.
e.g #include<iostream.h>
the above line include the header file iostream into the program for the smooth
running of the
program.

13. What is typecasting?


Type Casting
Explicit type casting operator
Type casting operators allow you to convert the data type of a given variable to
another. There are
several ways to do this
1.To precede the expression to be converted by the new type enclosed between
parentheses ( ) :
int i;
float f =3.14;
i = ( int ) f;
The previous code converts the float number 3.14 to an integer value (3), the
remainder is lost. Here,
the typecasting operator was (int).
2. Another way to do the same thing in C++ is using the functional notation:
preceding the expression to be converted by the type and enclosing the expression
between parentheses:
i = int (f );
Both ways of type casting are valid in C++.
14. Compilation and Linking
Compilation refers to the processing of source code files (.c, .cc, or .cpp) and the
creation of
an 'object' file. This step doesn't create anything the user can actually run. Instead,
the
compiler merely produces the machine language instructions that correspond to
the source
code file that was compiled. For instance, if you compile (but don't link) three
separate files,
you will have three object files created as output, each with the name <filename>.o
or
<filename>.obj (the extension will depend on your compiler). Each of these files
contains a
translation of your source code file into a machine language file -- but you can't
run them yet!
You need to turn them into executables your operating system can use. That's
where the
linker comes in.
Linking refers to the creation of a single executable file from multiple object files. In
this step,
it is common that the linker will complain about undefined functions (commonly,
main itself).
During compilation, if the compiler could not find the definition for a particular
function, it
would just assume that the function was defined in another file. If this isn't the
case, there's no
way the compiler would know -- it doesn't look at the contents of more than one file
at a time.
The linker, on the other hand, may look at multiple files and try to find references
for the
functions that weren't mentioned.

15. Diff between local(automatic) & global variables.


The lifetime and scope of local variables is the function or block in which they are
declared.
The lifetime and scope of global variables is the program in which they are declared.

16. How many cases are possible in a select case?


256, range of char.
17. What is difference between actual and formal parameters?
Actual Parameters
Variables associated with function name during function call statement.
Formal Parameters

Variables which contains copy of actual parameters inside the function definition.

18. What do you mean by entry controlled and exit controlled loop?
19. Entry control loop works for true condition and preferred for fixed no.of times.eg
for, while
20. Exit Control Loop execute at least once if the condition is false at beginning.eg
do while
21. Difference between signed and unsigned.
The range of signed data type is lower than unsigned as one byte is reserved to store
the sign(-, +)
Eg
For char datatype.
1byte signed: -128 to 127
unsigned: 0 to 255
22. What do you understand by .h in header file declarations?
23. .h stands for header files, an extension given to these types of files.
24. Why do we use comments? Declare a single line comment and a multi line comment.
COMMENTS in a C++ program.:
Comments are the line that compiler ignores to compile or execute. There are two
types of comments
in C++.
1. Single line comment: This type of comment deactivates only that line where
comment is
applied. Single line comments are applied with the help of “ //” .
e.g // cout<<tomorrow is holiday
the above line is proceeding with // so compiler wont access this line.
2. Multi line Comment: This Type of comment deactivates group of lines when
applied. This type of
comments are applied with the help of the operators “/*” and “*/ ”. These comment
mark with /*
and end up with */. This means everything that falls between /*and */ is
considered even though it
is spread across many lines.
e.g #include<iostream.h>
int main ()
{
cout<< “ hello world”;
/* this is the program to print hello world
For demonstration of comments */
}
In the above program the statements between /* and */ will be ignored by the
compiler.

25. Why do we use iostream.h?


To be able to connect the program to the input and output stream.
26. What is the difference between gets() and getline()?
27. What type of function is main()- user defined or in-built?
in-built
28. What happens during running
During running .exe and .bak files are created and the program is loaded in the ram.
29. Diff. between continue & break & exit
exit()- defined in process.h and used to terminate the program depending upon
certain condition.
break- exit from the current loop depending upon certain condition.
continue- to skip the remaining statements of the current loop and passes control
to the next loop control statement.

30. What are default arguments?

CHAPTER 2 OBJECT ORIENTED PROGRAMMING


Concepts of oops
Diff. between procedural programming and object oriented programming.

CHAPTER 3 CLASSES AND OBJECTS


Passing object through functions
Declaration& implementation of class, Diff between class & structure
Difference between object array and ordinary array?

CHAPTER 4 CONSTRUCTORS AND DESTRUCTOR


What will happen if we declare a constructor/ destructor in the private section of a
class?
Can we have a parameterized/ copy constructor in a class without having a default
constructor?
Implicit call and explicit call of constructors.
Uses of copy constructor
Uses of constructors& destructors & definition
How is a constructor different from a simple function?
Types of constructors
Constructor overloading
What is the concept of polymorphism? How is it implemented in C++?

CHAPTER 5 INHERITENCE
Various visibility modes in inheritance
Uses of function overloading and inheritance.
Name and elaborate on the types of Inheritance.
What do you understand by transitive nature in inheritance?

CHAPTER 6 DATA STRUCTURES


What are data structures?
Different types of data structures
CHAPTER 7 ARRAYS
Diff. B/W binary & linear search. Which one is better?
Array’s of structure are one dimensional & two dimensional
Diff between insertion , selection and bubble sort
How many bytes of data will be stored in each of the following :
a. char a[10];
b. int a1[10];

Difference between array and structures.

CHAPTER 8 STACKS AND QUEUES


Application of stacks & queues
Application of postfix expressions
What do you mean by Overflow and Underflow in the context of stacks?

CHAPTER 9 POINTERS
Difference between stack as an array and stack as a linked list.

Uses of pointers.
What is dynamic data structures ?
What is A in char A[10]
How can we declare dynamic arrays?
Consider the declaration : char *s[20] :- is it a 1-D or 2-D array ? Why?
What do you understand by static and dynamic memory? Give examples.
CHAPTER 11 FILE HANDLING
Differentiate between read and write function and explain them in detail.
Definition of file & stream
Diff between files and linked list
Diff between files & arrays
How are records implemented in C++?
Diff between binary & text files
Which is base class fstream / iostream
Difference between linked list and files.
Diff between file & array
Writing/Reading characters to/from file
Writing/Reading strings to/from file
Diff between text & binary file
Writing/Reading objects to/from file
Add / modifying / delete from a file

CHAPTER 12 MY SQL
What is DDL and DML?

76. Can we insert a new column into a table?

77. Can we delete a column from a table?

78. Can we delete a row from a table?

79. Can we insert a new row into a table?

I have item .dbf having fields item no. & category. Give command to count the total
number of items in each category

61. Student by having fields Roll no., Class, Section count total number of students
in each section of class XII. How can we make changes in one particular column of a
table

59. Diff between database & table


23. What happens when the drop table command is executed?
24. Explain all the cases of the like operator in SQL.
25. In SQL can MAX function be applied to date and char type date

GENERAL C++ VIVA QUESTIONS


1. PROJECT VIVA
a. Be thorough in your project. b. Logic used (in terms of storing data / reading text
files / manipulation of data) c. For application based projects
• Adding Records
• Modification
• Deletion
• Search on fields Binary file operations. d. Working of Project
In the first category i.e. “about project title” the few questions are: a) What is the
significance of this title? b) Why you choose this title? c) Are you think that this
title is suitable for Class XII ? d) Can you give any other title to your project work?
e) Can you explain your title of the project in 100 words? h) What does your project
do? i) How much time you taken in Analysis, Coding and Testing k) What are the
uses of the project?
2. C++ Concepts (Differences)
A. Fundamental Data Types Derived Data Types
• Basic Data Type • Derived from Basic Data types
• Int,char,void, float,double • Array,struct,class
B. Struct Class
• Members are Public by default Members are Private by default
C. Dynamic Memory Allocation Static Memory Allocation
• Allocated during Run Time using new operator
Allocated during compile time and fixed
• Memory can be deallocated during run time.
Memory can only be deallocated when scope gets over.
D.Call by Reference Call By value
• Value gets reflected at original location.
Value remains unchanged.
E. Global Variables Local Variables
Variables defined above all function definitions
Variables defined within a block or a function.
F. #define Macro Function Code gets substituted at place of function call.
Memory control is transferred at the place of function defined.
G= Assignment Operator = = Comparison Operator
Assigns a value to the variable. Compares the values and return 1 or 0.
H.Logical Operators Relational Operators
! Not, && AND, || OR < ,>, == , !=,>=,<=
I.Compile Time Errors Run Time Errors
Syntax errors occurs at compile time. Logical Errors occurs at Run Time
J.Member Functions Non member Functions
➢ Defined/Declared inside the class ➢ Defined Outside the class
➢ Public Member Functions are
accessed by object of that class
➢ Functions are called by their name
and object can passed as parameters.
K.Break Continue
➢ Takes the control out of the loop Takes the control back to next iteration.
LSwitch Case If..else
➢ Only used with char / int ➢ Only used for equality comparison
➢ Can be used with all data types ➢ Mix expressions can be evaluated.
M.Text Files Binary Files
➢ Data in ASCII format ➢ Not Secure and contains plain text
➢ Data in Binary form ➢ Data stored in blocks of object size.
N. File Pointer Position Opening Mode
Beginning Ios::in, ios::out, ios::app
End Ios::ate
O. Seeekg/Seekp Tellg/tellp
Place the file pointer at desired position Tells the current position of pointer
P. Statement Placement of file pointer
➢ f.seekg(0); Beginning
➢ f.seekg(40); 40 bytes ahead from beginning
➢ f.seekg(0,ios::end) End of file
➢ f.seekg(-10,ios::cur) 10 bytes back from current position.
Q. Stack Queue
➢ LIFO Manner ➢ FIFO Manner
➢ Only one end – Top ➢ Front – Deletion
➢ Rear - Insertion
R. Constructor Destructor
➢ Automatically called when object is declared
➢ Automatically called when object scope is over.
➢ Can be overloaded. ➢ Can’t be overloaded.
S. Strings as array and as pointer
char *str=”Computer”; char s[]=”Computer”;
1. sizeof(str) = 2 2. strlen(str) = 8
1. sizeof(str) = 9 2. strlen(str) = 8
T. Multilevel Inheritance Multiple Inheritance
A→B→C
AB
\/
C
U. While Do..while
Works till the condition is true. Executes atleast once even if the condition is false.
V File read and write
f.read((char*)&obj,sizeof(obj)); f.write((char*)&obj,sizeof(obj));
Two parameters : (char*)&obj – explicit typecasting, converting object into string of
size of object passed as parameter 2 , sizeof(obj) and reads from file and stores into
object.
Two parameters : (char*)&obj – explicit typecasting, converting object into string of
size of object passed as parameter 2 , sizeof(obj) and writes object to file .
W. Function Prototype Function Defintion
Function Header with list of parameters passed, return type mentioned, ended with
a;. Must match with Function header of defined body.
Function containing body/statements to be executed.
X. Reference Variable typedef
Alternate of a Variable . Int &ch=a; Ch is alternate name of a,share common
location.
Typedef gives name to a datatype. Typedef float amount;
Y. Function Overloading Function Overriding
Overloading - Two functions having same name and return Type, but with different
type
Overriding - When a function of base class is re-defined in the derived class.
and/or number of arguments.
Z. Arrays Pointers
Array –array use subscripted [] variable to access and manipulate the data ,array
variables can be equivalently written using pointer expression
Pointer –pointer is a variables that hold the address of another variable .It is used
to manipulate data using the address, pointer use the * operator to access the data
pointed by them
Copy constructors are called in following cases: a) when a function returns an
object of that class by value b) when the object of that class is passed by value as
an argument to a function c) when you construct an object based on another object
of the same class d) When compiler generates a temporary object MORE Questions
(Answer to the point)
1. What is inheritance? 2. What is Polymorphism? 3. Is class an Object? Is object a
class? 4. Why destructors invoke in reverse order? 5. What is role of constructor?
6. Why we need constructors? 7. What property of OOP is implemented in
Constructors? 8. Can destructors be overloaded Yes/No & Why? 9. Can
constructors be overloaded Yes/No & Why? 10. What is difference between default
constructor and constructor with default arguments? 11. Does any value is
returned by Constructors? 12. Why the reference of an object is passed in copy
constructor? 13. When copy constructor is invoked? 14. From the given conditions
(1) Sample S1=S2; (2) S1=S2 ; When copy constructor will invoke. 15. if a derived
class has no parameters for its constructor but a base class has parameterized
constructor , how the constructor for the derived class would defined? 16.
Difference between for and while loop.
EXPECTED VIVA questions(SOLVED)
What is a class?
Class is concrete representation of an entity. It represents a group of objects, which
hold similar attributes
and behavior. It provides Abstraction and Encapsulations. Classes are generally
declared using the keyword
class.
2. What is an Object? What is Object Oriented Programming?
Object represents/resembles a Physical/real entity. An object is simply something
you can give a
name. Object Oriented Programming is a Style of programming that represents a
program as a system
of objects and enables code-reuse.
3. What is Encapsulation?
Encapsulation is binding of attributes and behaviors. Hiding the actual
implementation and exposing
the functionality of any object. Encapsulation is the first step towards OOPS, is the
procedure of
covering up of data and functions into a single unit (called class). Its main aim is to
protect the data
from out side world
4. What is Abstraction?
Hiding the complexity. It is a process of defining communication interface for the
functionality and
hiding rest of the things.
5. What is Overloading?
Adding a new method with the same name in same/derived class but with different
number/types of
parameters. It implements Polymorphism.
6. What is Inheritance?
It is a process in which properties of object of one class acquire the properties of
object of another
class.
7. What is an Abstract class?
An abstract class is a special kind of class that cannot be instantiated. It normally
contains one or more
abstract methods or abstract properties. It provides body to a class.
8. What is Polymorphism? And its type?
1. What do you mean by iostream.h?
2. What is inheritance and its type?
3. What is the difference b/n public, private and protected?
● Public: The data members and methods having public as access outside the
class.
● Protected: The data members and methods declared as protected will be
accessible to the class methods and the derived class methods only.
● Private: These data members and methods will be accessible not from objects
created outside the class. 4. What is a void return type?
A void return type indicates that a method does not return a value.
5. What is the difference between a while statement and a do statement?
A while statement checks at the beginning of a loop to see whether the next
loop iteration should occur. A do statement checks at the end of a loop to see
whether the next loop iteration should occur.
6. What is a nested class? Why can it be useful?
A nested class is a class enclosed within the scope of another class. For
example: // Example 1: Nested class // class Outer Class {class Nested Class
{// ...}; //... What is preprocessor?
The preprocessor is used to modify your program according to the
preprocessor directives in your source code. Preprocessor directives (such as
#define) give the preprocessor specific instructions on how to modify your
source code. The preprocessor reads in all of your include files and the source
code you are compiling and creates a preprocessed version of your source
code. This preprocessed version has all of its macros and constant symbols
replaced by their corresponding code and value assignments. If your source
code contains any conditional preprocessor directives (such as #if), the
preprocessor evaluates the condition and modifies your source code
accordingly. The preprocessor contains many features that are powerful to
use, such as creating macros, performing conditional compilation, inserting
predefined environment variables into your code, and turning compiler
features on and off. For the professional programmer, in-depth knowledge of
the features of the preprocessor can be one of the keys to creating fast,
efficient programs. 7. What are memory management operators?
There are two types of memory management operators in C++:
● new
● delete
Constructors
A special function Always called whenever an instance of the class is created.
● Same name as class name
● No return type
● Automatically call when object of class is created
● Used to initialize the members of class
● class Test
{ int a,b;
Test()
{ a=9;b=8; } };
Here Test() is the constructor of Class Test.
8. What is copy constructor?
Constructor which initializes it's object member variables ( by shallow copying) with
another object of the same class. If you don't implement one in your class then
compiler
implements one for you.
for example:
○ Test t1(10); // calling Test constructor
Test t2(t1); // calling Test copy constructor
Test t2 = t1;// calling Test copy constructor
● Copy constructors are called in following cases:
● when a function returns an object of that class by value
● when the object of that class is passed by value as an argument to a function
● when you construct an object based on another object of the same class
9. What is default Constructor?
Constructor with no arguments or all the arguments has default values. In Above
Question Test() is a
default constructor
10. What is a scope resolution operator?
A scope resolution operator (::), can be used to define the member functions of a
class outside the
class.
1. What are the advantages of inheritance?
It permits code reusability. Reusability saves time in program development. It
encourages the reuse of
proven and debugged high-quality software, thus reducing problem after a system
becomes functional

Potrebbero piacerti anche