Viva Mix Questions
Viva Mix Questions
Q1. What is # ?
Ans. .h
Ans. getch() – it is used to get a char, until you press the character the output screen is shown
and clrscr() – it is used to clear the entire previous outputs/clear screen.
Ans. cout() – it is used to display the contents and cin()- it is used to read the content or to
take input.
Ans. .cpp
Ans. C with classes, the idea of C++ comes from the increment operator of C language.
Q11. What is OOPs?
Ans. The object oriented programming has main emphasis on object rather than procedure. It
follows bottom- up approach.
Ans. The main function is in bottom i.e. after class declaration, therefore, the execution of the
program must be from bottom.
Ans. The procedure oriented programming has emphasis on procedure. It follows top-down
approach.
Ans. The main function is declared on the top of the program, therefore, the execution of the
program must be from top.
Ans. Class, object, polymorphism, inheritance, data encapsulation and data abstraction,
message passing.
Inheritance – it means the new class may acquire the properties of the existing class, it
provides the idea of ‘reusability’.
Encapsulation – the wrapping up of a data and function into a single unit called class.
protected – data and functions must be accessible to base class and child class
Ans. Constant values remain static while variable values keeps on changing throughout the
program.
Q27. What is the difference between call by value and call by reference ?
Ans. In call by value, the called function creates its own copies of the original values sent to
it.
In call by reference, the called function accesses and works with the original values using
their references(addresses).
Q31.What is scope ?
Ans. The program area inside which a variable or a function can be used.
Ans. A member function having the same name as its class. It initializes class objects with
legal initial values.
Ans. A constructor that initializes an object with the data values of another object.
Ans. A member function having the same name as its class but preceded by tilde sign (~). It
reinitializes an object before it goes out of scope or simply , to destroy the object created by
constructor.
Ans. Giving several definitions to a single function name that are differentiable by the
number or types of their arguments.
Ans. A class from which another class inherits (also called super class).
Ans. A class inheriting properties from another class (also called sub class).
Ans. Structured Query Language- A language that creates and operates on relational
database.
Ans. Data Definition Language provides commands for defining relation schemes, deleting
relations.
Data manipulation Language includes a query language to insert , update, delete and
modify tuples in the database.
Ans. An interface between computer and user. Eg. Windows, linux, unix, vista etc.
Ans. An input devices is any hardware component used to enter data, programs, commands,
and user responses into a computer. e.g. Keyboard, mouse, lightpen , touch screen , joystick ,
microphone etc.
Ans. An output devices produce output of the machine in human readable form. Eg. Printer,
moniter, speakers, plotter etc.
3. Generation of Computer: The computer has experienced five generations, with the
fifth generation still very much in development.
-First Generation
-Second Generation
-Third Generation
-Fourth Generation
-Fifth Generation
4. I/O Devices
Input device
Keyboard Mouse
MICR OCR
OMR Light Pen
Output Unit
VDU (Monitor) Printer
Plotter
5. Storage Devices
Hard Disk
Magnetic Tape
Floppy Disk
Optical Disk
Punched Card
6. System Software
Compiler
Interpreter
Operating System
7. Application Software
Databases
Word processors
Spreadsheet
Unit – II
1. Basic elements of assembly language are:
Labels
Instructions
Operands
Directives
Comments .
2. Assembly Scheme
Synthesis Phase
Analysis Phase
5. Nested Macro Call: A model Statement in a macro may constitute a call on another
macro. Such calls are known as nested macro call.
Advanced Macro facilities
4. Ordered Indexes: An ordered file that stores the index field and a pointer. Requires a
binary
search on the index file
Types of Ordered Indexes
Primary
Clustering
Secondary
5. Secondary Indexes: A secondary index is an ordered file that stores the no ordering
field of a data file and a pointer. If the indexing field is a secondary or candidate key,
then the index is dense. If the indexing field is a nonkey field, then the index is
sparse. Introduces the idea of adding a level of indirection
1. C++ basics, loops and decisions
Object oriented programming encourage you to decompose a problem into its constituent
parts. Each component becomes a self-contained object that contains its own instructions
and data that relate to that object. In this way, complexity is reduced and the programmer
can manage larger program.
A function is a group of statements that is executed when it is called from some point of
the program. The following is its format:
where:
type is the data type specifier of the data returned by the function.
name is the identifier by which it will be possible to call the function.
parameters (as many as needed): Each parameter consists of a data type specifier
followed by an identifier
statements is the function's body. It is a block of statements surrounded by braces { }.
A class is an expanded concept of a data structure: instead of holding only data, it can
hold both data and functions.
An object is an instantiation of a class. In terms of variables, a class would be the type,
and an object would be the variable.
Classes are generally declared using the keyword class, with the following format:
class class_name {
access_specifier_1:
member1;
access_specifier_2:
member2;
...
} object_names;
Where class name is a valid identifier for the class, object names is an optional list of
names for objects of this class. The body of the declaration can contain members, that can
be either data or function declarations, and optionally access specifies.
4. Object Array
Objects are variables and have the same capabilities and attributes as any other type of
variables. Therefore, it is perfectly acceptable for objects to be arrayed. The syntax for
declaring an array of objects is exactly as that used to declare an array of any other type
of variable. Further, arrays of objects are accessed just like arrays of other types of
variables.
#include < iostream >
class classname
{
};
void main( )
{
classname ob[4]; //array of 4 objects
}
5. Constructors and Destructor functions
Objects generally need to initialize variables or assign dynamic memory during their
process of creation to become operative and to avoid returning unexpected values during
their execution.
A class can include a special function called constructor, which is automatically called
whenever a new object of this class is created. This constructor function must have the
same name as the class, and cannot have any return type; not even void
The destructor fulfills the opposite functionality. It is automatically called when an
object is destroyed, either because its scope of existence has finished (for example, if it
was defined as a local object within a function and the function ends) or because it is an
object dynamically assigned and it is released using the operator delete.
The destructor must have the same name as the class, but preceded with a tilde sign (~)
and it must also return no value
#include < iostream >
class classname {
public:
myclass( ); //constructor
~myclass( ); //destructor }
1. Operator and function overloading:
Function Overloading: Two or more functions can share the same name as long as
either the type of their arguments differs or the number of their arguments differs - or
both. When two or more functions share the same name, they are said overloaded.
Overloaded functions can help reduce the complexity of a program by allowing related
operations to be referred to by the same name.
To overload a function, simply declare and define all required versions. The compiler
will automatically select the correct version based upon the number and/or type of the
arguments used to call the function.
Operator overloading: Operator overloading is the ability to tell the compiler how to
perform a certain operation when its corresponding operator is used on one or more
variables. To overload an operator in order to use it with classes we declare operator
functions, which are regular functions whose names are the operator keyword followed
by the operator sign that we want to overload. The format is:
data type operator sign (parameters) { /*...*/ }
Here you have an example that overloads the addition operator (+). We are going to
create a class to store bidimensional vectors and then we are going to add two of them:
a(3,1) and b(1,2). The addition of two bidimensional vectors is an operation as simple
as adding the two x coordinates to obtain the resulting x coordinate and adding the two y
coordinates to obtain the resulting y. In this case the result will be (3+1,1+2) = (4,3).
A key feature of C++ classes is inheritance. Inheritance allows to create classes which are
derived from other classes, so that they automatically include some of its "parent's"
members, plus its own. For example, we are going to suppose that we want to declare a
series of classes that describe polygons like our CRectangle, or like CTriangle. They
have certain common properties, such as both can be described by means of only two
sides: height and base.
This could be represented in the world of classes with a class CPolygon from which we
would derive the two other ones: CRectangle and CTriangle.
In order to derive a class from another, we use a colon (:) in the declaration of the
derived class using the following format:
class derived_class_name: public base_class_name
{ /*...*/ };
Where derived_class_name is the name of the derived class and base_class_name is
the name of the class on which it is based. The public access specifier may be replaced
by any one of the other access specifiers protected and private. This access specifier
describes the minimum access level for the members that are inherited from the base
class.
The objects of the classes CRectangle and CTriangle each contain members inherited
from CPolygon. These are: width, height and set_values().
The protected access specifier is similar to private. Its only difference occurs in fact
with inheritance. When a class inherits from another one, the members of the derived
class can access the protected members inherited from the base class, but not its private
members.
Since we wanted width and height to be accessible from members of the derived classes
CRectangle and CTriangle and not only by members of CPolygon, we have used
protected access instead of private.
Multiple Inheritance:
In C++ it is perfectly possible that a class inherits members from more than one class.
This is done by simply separating the different base classes with commas in the derived
class declaration. For example, if we had a specific class to print on screen (COutput) and
we wanted our classes CRectangle and CTriangle to also inherit its members in addition
to those of CPolygon we could write:
Features of a database.
It is a persistent (stored) collection of related data.
The data is input (stored) only once.
The data is organised (in some fashion).
The data is accessible and can be queried (effectively and efficiently).
So a database is a collection of related data that we can query effectively and efficiently.
Advantages.
Eliminates redundancy and avoids inconsistency
Confidentiality,
Supports multiple, concurrent users
Privacy, and
Security
DATA MODELING
It consists of some concepts to describe the structure of database i.e. data type,ralations, and constraints that
should hold on the data. Eg. ER model
Logical data modeling is a graphic-intensive technique that results in a data model representing the definition,
characteristics, and relationships of data in a business, technical, or conceptual environment. Its purpose is to
describe end-user data to systems and end-user staff.
Various methods of data modeling exist, each using a host of conventions and tools. The most popular
approach is called the entity-relationship (ER) approach, developed by Peter Chen in the late 1970s. Although
a number of authors and tool designers have modified and expanded ER concepts, most still have a strong
Chen flavor. Also, with the introduction of CASE tools, the number of diagrammatic conventions that the
data modeler must master has increased sharply.
Data Modeling Objects
The three types of data objects--entities, attributes, and relationships--are the basic building
blocks of modeling:
Entities are persons, places, or things about which an organization wishes to save
information. Employees, States, Orders, and Time Sheets are examples of entities. (As a
convention, I capitalize the first letter of entities.)
Attributes are the properties of entities. Attribute examples include Color, Employment
Date, Name, and Social Security Number. (As a convention, I write attributes in all
upper-case letters.)
Relationships are verbs that describe how entities relate to each other; for example:
'Customers Buy Products,' 'Employees File Time Sheets,' 'Salespeople Place Orders.' A
sentence in this entity-relationship-entity construct is called a "relationship entity pair,"
which is a fashionable mechanism for representing relationships. Relationship entity pairs
are bidirectional. Therefore, 'Customers Buy Products' is the same as 'Products are
Bought by Customers.' "Relationship" describes an end-user relationship, not a technical
one. (As a convention, I capitalize the first letter of relationship names, and capitalize the
first letter of relationship entity pairs and put them in single quotes.)
Database Users
Following are the types of database users:
Database Administrator - a database administrator performs the following activities:
o Monitoring performance
o Granting user authority to access the database
Application programmers
Data analysts
Naive users
Entity-relationship model
The E-R (entity-relationship) data model views the real world as a set of basic objects
(entities) and relationships among these objects. This represents the overall logical
structure of the DB.
An Entity-relationship model is a relational schema database modeling method used to model a system and its
requirements in a top-down approach. This approach is commonly used in relational (RDBMS) database
design. The diagrams created using this method are called ER diagrams.
An entity-relationship model (ERM) is an abstract conceptual representation of structured data; entity-
relationship modeling is the process of generating these models. The end-product of the modeling process is
an entity-relationship diagram (ERD) or ER diagram, a type of conceptual data model or semantic data
model
The E-R (entity-relationship) data model views the real world as a set of basic objects
(entities) and relationships among these objects. It is intended primarily for the DB design
process by allowing the specification of an enterprise scheme. This represents the overall
logical structure of the DB.
Generalization/Specialization
Generalization/Specialization represents the is a relationship set , an essential element of the object oriented
paradigm. The main idea in Generalization/Specialization is that one object class (the specialization) is a
subset of another (the generalization).
Kind of Relations
One-To-One Relation
A very simple relation between two tables is an one-to-one relation. Using this relation, for every row in the
first table exactly one other row in the second table is assigned. The relation is reflected in the object world
using a reference to another object.
One-To-Many Relation
This kind of relationship is an extension of one-to-one relations. You should understand the concepts behind
one-to-one relations before reading this chapter.
Using one-to-many relations, you cannot only model a reference to a single object of same or different type,
but as many references as you like.
Many-To-Many Relation Mapping
This relationship type extends the one-to-many relations by the ability to assign from one tables row to more
than one row from the other table and vice versa. These relations are stored in a separate third table, the so-
called lookup table. Both source tables do not contain any information that deals with relations
Relational database
A relational database is a collection of data items organized as a set of formally-described tables from which
data can be accessed or reassembled in many different ways without having to reorganize the database tables.
The relational database was invented by E. F. Codd at IBM in 1970.
Various types of Keys
There are various types of relational keys (foreign keys are another issue and discussed
separately):
Candidate Key
A candidate key is any set of one or more columns whose combined values are unique
among all occurrences (i.e., tuples or rows). Since a null value is not guaranteed to be
unique, no component of a candidate key is allowed to be null.
Primary Key
The primary key of any table is any candidate key of that table which the database
designer arbitrarily designates as "primary". The primary key may be selected for
convenience, comprehension, performance, or any other reasons. It is entirely proper to
change the selection of primary key to another candidate key.
Alternate Key
The alternate keys of any table are simply those candidate keys which are not currently
selected as the primary key. According to Date95, "... exactly one of those candidate keys
[is] chosen as the primary key [and] the remainder, if any, are then called alternate keys."
An alternate key is a function of all candidate keys minus the primary key.
Superkey
A Superkey is defined in the relational model of database organisation as a set of attributes of a relation
variable (relvar) for which it holds that in all relations assigned to that variable there are no two distinct tuples
(rows) that have the same values for the attributes in this set. Equivalently a Superkey can also be defined as a
set of attributes of a relvar upon which all attributes of the relvar are functionally dependent.
Note that if attribute set K is a Superkey of relvar R, then at all times it is the case that the projection of R over
K has the same cardinality as R itself.
Informally, a Superkey is a set of columns within a table whose values can be used to uniquely identify a row.
A candidate key is a minimal set of columns necessary to identify a row, this is also called a minimal
Superkey.
Foreign key
In the context of relational databases, a foreign key is a referential constraint between two tables.[1] The
foreign key identifies a column or a set of columns in one (referencing) table that refers to a column or set of
columns in another (referenced) table. The columns in the referencing table must form a primary key or
unique key in the referenced table. The values in one row of the referencing columns must occur in a single
row in the referenced table. Thus, a row in the referencing table cannot contain values that don't exist in the
referenced table. This way references can be made to link information together and it is an essential part of
database normalization. Multiple rows in the referencing table may refer to the same row in the referenced
table. Most of the time, it reflects the one (master table, or referenced table) to many (child table, or
referencing table) relationship.