0% found this document useful (0 votes)
9 views

Computer Science QnA

Uploaded by

joshuaagera23s
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Computer Science QnA

Uploaded by

joshuaagera23s
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Computer Science QnA

Chapter-1: Typical configuration of Computer system


1. Define motherboard. Explain the types of motherboards.

Ans) A large Printed circuit board which is the main circuit of the computer containing various components

2. Explain the characteristics of motherboard.

Ans) (i) Form Factor- refers to motherboards geometry, dimensions, requirements

(ii) Chipset- Coordinates data transfer b/w various components of the computer

(iii) Processor socket- Rectangular/square shaped connector

3. Define cache memory. Explain any two types.

Ans) Cache Memory is a very high-speed semiconductor memory. It can speed up CPU. It acts as a buffer between the CPU and main memory. The types of cache are:

L1 (Level-1) cache: Cache that is integrated within the processor.

L2 (Level-2) cache: Its located on the motherboard, outside the processor.

4. Define slots. Explain any three types of slots.

Ans) Opening in a computer to insert a printed circuit board. Expansion slots add functionality to the computer.

1) The AGP (Accelerated Graphics Port) slot is for inserting Graphics (video) card which make graphics application run faster.

2) Processor Slot - The processor is usually the largest chip on the system board Processor slot is used to fit processor on the mother board.

3) RAM Slots: Random-Access Memory (RAM) stores programs and data currently being used by the CPU. There are typically two types of sockets to install memory
they are

SIMM (Single Inline Memory Module) sockets

DIMM (Dual Inline Memory Module) sockets.

5. Define BUS. Explain its types.

Ans) Its a collection of wire that carries electronic signals from one component to another. There are 2 types:

(i) Internal bus or System bus - It connects major components of a computer such as the CPU, memory and I/O

(ii) External bus or Expansion bus – connects the different external devices, expansion slots, I/O ports and drive connections to the rest of computer.

6. Define I/O ports. Explain the different types of ports.

Ans) A socket on the back of the computer used to connect external device to the computer is called por. The different I/O ports are serial, parallel, SCSI, game and USB
ports.

a) Serial Ports: Also called RS-232-C ports. Its used to connect modems and some type of printers. When data is sent out a serial port, it is sent 1 bit at a time.
Advantage is that the data is sent and received over only two lines.

b) Parallel Ports: Its reserved for printers and some types of external storage devices. They carry 8 bits of data at a time on parallel paths. The signals do not travel as
far as the signals of serial port. The printer is attached through a parallel port.

c) SCSI Ports (Small Computer System Interface) port High performance hard-disks, high-end scanners and CD-ROM drives use the SCSI interface for fast data transfers
and I/O operations.

d) Game port: connects a PC to a joystick. Game ports are fitted onto sound cards and display cards. The game port are used to attach gaming devices like joysticks to
the computer

e) USB Ports : USB port gives a single, standardized, easy-to-use way to connect a variety of peripherals (printers, scanners, digital cameras, web cameras, speakers,
etc) to a computer. USB is a plug and play interface between a computer and add-on devices. A new device can be added to the computer without adding an
adapter card or even turning the computer off

7. Explain different types of UPS.

Ans) There are two types of UPS:

Online UPS - In Online UPS, the Inverter is directly connected to the device and it always on to give the required current to the device. If power fails, the battery backup
circuit switches on and takes the load. Online UPS is more efficient than the Offline.

Off line UPS - In Offline UPS the device is directly connected to the input current. The UPS circuit always monitors the voltage level in mains and if there is a voltage drop or
main failure it switches to the inverter.

Chapter-4: Data Structures


1. Explain the operations performed on primitive data structures.

Ans) 1)Create- to create a new data structure. E.g. int a;


2)Destroy - to remove the data structure from memory space.

3)Select - to access the data within the data structure.

4)Update – to change the data of the data structure.

2. Explain the operations performed on linear data structures.

Ans) Traversal – visiting each subscript at least once to perform some operation from the beginning to last element is called traversal
Insertion – adding new data item into the given collection of data items is called insertion.

Deletion – removing an existing data item from the given collection of data items is called deletion.

Searching –finding the location of a data item in the given collection of data items is called searching.

Sorting – arrangement of data items in ascending or descending order is called sorting.

Merging – combining the data items of two structures to form a single structure is called merging.

3. Algorithm to perform PUSH and POP.

Ans)

Push Algorithm (inserting an element in stack) POP Algorithm (deleting an element from stack)
Step 1: If Top=n-1 Then Step 1:If Top=-1 Then
Print “Stack is full” Print “Stack is empty or underflow”
[Exit] Exit
[EndIf] [EndIf]
Step 2: Top=Top+1 Step 2:Item=Stack[Top]
Step 3: Stack [Top]=Item Step 3:Top=Top-1
Step 4: Return Step 4:Return

4. Explain the operations performed on stacks.

Ans) 1) stack() – creates a new empty stack.

2)push(item) – adds a new item to the top of the stack.

3)pop() – removes the top item from the stack.

4)peek() – returns (displays) the topmost item from the stack.

5)isEmpty() – checks whether the stack is empty. (underflow)

6)size() – returns (displays) the number of items on the stack.

5. Algorithm to insert and delete an element from one dimensional Array.

Inserting an element in an array Deleting an element from an array


Step 1: For i=n-1 downto p Step 1: item=a[p]
a[i+1]=a[i] Step 2: For i= p to n-1
[EndFor] a[i]=a[i+1]
Step 2: a[p]=Item [EndFor]
Step 3: n=n+1 Step 3: n=n-1
Step 4: Exit Step 4: Exit

6. Algorithm to insert and delete an element from the queue.

Ans)

Insert a data element of the queue: - Delete an element queue:-

Step 1:If Rear=n-1 Then Step 1:If Front=-1 Then


Print “Overflow” Print “Queue is empty / Underflow”
Exit Exit
[EndIf] [EndIf]
Step 2:If Front=-1 Then Step 2:Item=Queue[Front]
Front=0 Step 3:If Front=Rear Then
Rear=0 Font=0
Else Rear=0
Rear=Rear+1 Else
[EndIf] Front=Front+1
Step 3:Queue[Rear]=Item [EndIf]
Step 4:Return Step 4:Return

7. Explain memory representation of one-dimensional array.

Ans) Loc(a[p])=Base(a)+w(p-Lb)
int a[5]={10,20,30,40,50};

Address Content Location

1000 10 a[0]

1001

1002 20 a[1]

1003

1004 30 a[2]

1005

1006 40 a[3]

1007
1008 50 a[4]

1009

Now the address of element a[3] = Base(a)+w(p-Lb) = 1000+2(3-0) =1000+2*3=1006

8. Explain memory representation of two-dimensional arrays in row major order.


Ans) Row-major ordering - Elements present in the first row occupies the allocated memory first. Later elements stored in the subsequent rows are stored in the memory. An actual address
of the particular element is calculated with the formula.

Loc(A[row][Col]=Base_address+Word_size(Number_of_Rows x Row + Column)

9. Explain memory representation of two-dimensional arrays in column major order.


Ans) Column-major ordering - elements present in the first column occupies the allocated memory first. Later elements present in the subsequent columns are stored in the memory. An
actual address of the particular element is calculated with the formula.

Loc(A[row][Col]=Base_address+Word_size(Number_of_Columns x Column+ Row)

10. How do you initialize one dimensional array?

Ans) data_type array_name[size]={values};

E.g. int a[5]={};

11. What are the applications of array?

Ans) 1) To implement stacks, queues, linked lists, trees, graphs, etc.

2) To implement mathematical vectors and matrixes

12. Mention the applications of Queues.

Ans) Simulation, Operating systems, Process management, Different applications software, Printer server routines

13. Algorithm for traversal of an element in an array.

Ans) Step 1: For i=Lb to Ub

Process a[i]

[EndFor]

Step 2: Exit

14. Algorithm to perform binary search.

Ans)
Step 1: loc=-1
Step 2: first=0
Step 3: last=n-1
Step 4: While(first<=last)
mid=(first+last)/2
If(item=a[mid])
loc=mid
Goto Step 5
Else If(item>a[mid])
first=mid+1
Else
last=mid-1
[EndIf]
[EndWhile]
Step 5:If(loc>=0)
Output “Element is found at position= “,loc
Else
Output ”Element is Not Found”
[EndIf]
Step 6:Exit

15. Algorithm to perform insertion sort.

Ans)
Step 1: For i=1 to n-1
j=i
While(j>=1)
If(a[j]<a[j-1])
temp=a[j]
a[j]=a[j-1]
a[j-1]=temp
[EndIf]
j=j-1
[EndWhile]
[EndFor]
Step 2: Exit

Chapter-6: Basic Concepts of OOPS


1. Explain the difference between object-oriented programming over procedural programming.

Ans)
Procedural Programming / Procedure Oriented Programming (POP) Object Oriented Programming (OOP)
Variables Objects
Follows top down approach Follows bottom up approach
No access specifier Has access specifier (private, public and protected)
No data hiding Data hiding
Overloading not possible Overloading is possible

2. Explain the characteristics of OOPs.


Ans) Classes and Objects - The programs are modularized based on the principle of classes and objects.

Abstraction – Its the process of representing essential features without including the background details or explanation.

Encapsulation (Data hiding) - Combining data and associated functions into a single unit. External non-member function cannot access or modify data, thus providing data security.

Inheritance – The capability of a class to inherit the properties of another class. Types of inheritance are single level, multi level, multiple, Hierarchical and Hybrid Inheritance.

Polymorphism (Function overloading) – Polymorphism is an ability of a function to have same name and multiple forms. Function overloading means two or more functions have same
name, but differ in the number of arguments or data type of arguments.

Message passing - OOP communicates through message passing. A message is request for execution of procedure (message passing is calling a function. It involves specifying the name of an
object, the member function and the arguments to be passed if any)

OOP allows overloading where objects can have different meaning depending upon context.

3. Write the advantages and disadvantages of OOPS.

Ans)

Advantages of OOP Disadvantages of OOP


programs modularized based on classes and objects. OOP software is not having set standards
Code reusability. Adaptability of flow diagrams and object-oriented
programming using classes and objects is difficult.
Reduces code duplication. Classes are too generalized
Data security (data encapsulation) – data hiding is Conversion of a real-world problem into an object-
possible oriented model is difficult.
Much suitable for large projects. Special skills are required for a programmer.

4. Write the applications of OOPs.

Ans) Object-oriented Database.

Windows

Real-time systems

AI and expert systems.

Image processing.

Web based applications.

Mobile computing.

Chapter-7: Classes and Objects


1. Define object. Write syntax and example for declaring an object.

Ans) An object is an instance of a class. It is the real-world entity. An object is normally defined in the main() function.

Syntax: class-name object-name1, object-name2,…;

Example: sum obj1, obj2;

2. Write the syntax and example for accessing class members.

Ans) Syntax for accessing a data member of a class

ObjectName.DataMember;

Syntax for accessing a member function of a class

ObjectName.MemberFunctionName(arguments);

Example:- obj.input();

3. Explain with syntax and example for class definition and class declaration.

Ans)

Syntax Example
class class-name class sum
{ {
private: private:
Member data; int a,b,s;
Member functions public :
protected: void input()
Member data; {
Member functions cin>>a>>b;
public: }
Member data; void process()
Member functions {
}; s=a+b;
}
void output()
{
cout<<s;
}
};

4. Explain with syntax and example for defining a member function outside the class.

Ans)

Syntax Example
return-type class-name :: function-name(argument1, argument2,...) class sum
{ { private:
Body of function int a,b,c;
} public :
void input();
};
void sum :: input()
{
cin>>a>>b;
}

5. Explain with syntax and example for defining a member function inside the class.

Ans)

Syntax Example
class class-name class sum
{ {
Access specifier: private:
return-type function-name(argument1, int a,b,s;
argument2,...) public :
{ void input()
Body of the function {
} cin>>a>>b;
}; }
void process()
{
s=a+b;
}
void output()
{
cout<<s;
}
};

6. Explain array of objects.

Ans) Array having class type elements is known as array of objects. An array of objects is declared after class definition. Its defined in the same way as any other array. The
declaration of an array of class objects is similar to the array of structures in C++.

7. Write the difference between class and structure.

Ans) Structure (struct) Class (class)

It contains only data members It contains data members and member functions

By default data members are public By default data members are private

A keyword struct is used for definition A keyword class is used for definition

No access specifers used access specifers (private, protected, public) used

No data hiding (not secured) Data hiding (secured)

8. Explain array as data members.

Ans) An array is used as data members when large number of similar type of data members are considered. These data
members can be accessed by using corresponding subscripts.
Example:
class sample Chapter-8: Function overloading and
{ private :
int a[100],i; member functions
public :
1. void input(); Define function overloading. Explain with
- syntax and example.
-
Ans) }; Function overloading means two or more
void sample :: input()
{
functions have same name, but differ in
the cout<<”Enter 5 numbers\n“; number of arguments or data type of
for(i=0;i<5;i++) arguments
cin>>a[i];
}

Syntax Example
Return-type function-name(arguments..) #include<iostream.h>
#include<conio.h>
{ #include<math.h>
class fo
Body of the function {
} private:
float s;
public:
float area(float a)
{
return (a*a);
}
float area(float a, float b)
{
return (a*b);
}
float area(float a, float b, float c)
{
s=(a+b+c)/2;
return (sqrt(s*(s-a)*(s-b)*(s-c)));
}
};
void main()
{
float a,b,c;
fo obj;
cout<<”Enter value of a, b and c \n”;
cin>>a>>b>>c;
cout<<"Area of the square = "<<obj.area(a);
cout<<"Area of the rectangle = "<<obj.area(a,b);
cout<<"Area of the triangle = "<<obj.area(a,b,c);
}

2. Write the need/advantages of function overloading.

Ans) Faster code execution.

Easier to understand the flow of information and debug.

Easier code maintenance.

Easier interface between programs and real world objects.

Eliminates the use of different function names.

Reduced program complexity.

3. Write the features/characteristics of inline function.

Ans) Inline functions are defined inside the class before other functions of that class.

The definition of inline functions begin with the keyword inline.

Inline functions are small and simple.

Inline function run faster than normal functions.

Function defined outside the class can be made inline including the keyword inline

4. What are the advantages and disadvantages of inline functions?

Advantages Disadvantages
• Inline functions are small in size and compact. • The size of the executable file increases and
• Inline functions are executed faster than other requires more memory, if its called frequently
functions. • It does not work if the definition is long and
• Efficient code can be generated. complicated, contains looping/switch/goto
• Readability of the program is increased. statements and there are recursive calls.

5. Define inline functions. Explain with syntax and example.

Ans) A function whose body is inserted at the place of its call is called inline function. It reduces overhead and increases the speed of the function.

6. Write the characteristics of friend function.

Ans)Friend functions are non-member functions that are given special access privileges.

It has access to private and protected members of the class.

Two classes can share a common function.

It is declared by the class that is granting access.

Friend function is declared with the keyword ‘friend’.

7. Define friend functions. Explain with syntax and example.

Ans)

Syntax Example
class class_name #include <iostream.h>
{ #include<conio.h>
public: class sum
{
friend return_type function_name(argument/s);
private:
}; int a, b;
return_type function_name(argument/s) public:
void input()
{ {
- cout<<”Enter 2 numbers \n”;
cin>>a>>b;
} }
friend int add(sum obj);
};
int add(sum obj)
{
return (obj.a + obj.b);
}
void main()
{
clrscr();
sum obj;
obj.input();
cout << "Sum = "<<add(obj);
getch();
}

Chapter-9: Constructors and Destructors


1. Define constructor.

Ans) A constructor is a special member function that is used in classes to initialize the objects of a class automatically

2. Mention the rules/features of constructor.

Ans) Constructor name is same as that of class.

Constructor does not return any value.

Constructor is used can to set initial values for certain member variables.

Constructor is declared in the public section of a class

Constructor is invoked automatically when the object is created

Constructor can be called implicitly or explicitly

Overloading of constructors is possible.

If there is no constructor defined for a class then compiler will call the default constructor.

Constructor can be defined within the class or outside the class

It is not possible to refer to the address of the constructors

3. Explain default constructor with syntax and example.

Syntax Example
class ClassName class series
{
{ private :
public : int x, n, i, s;
public :
ClassName()
series()
{ {
//default constructor s=1;
}
} void input();
}; void process();
void output();
};
…..
void main()
{
clrscr();
series obj;
obj.input();
obj.process();
obj.output();
getch()
}

4. Explain the different methods of invoking a parameterized constructor.

Ans)

Method 1: implicit Call to constructor

This method creates an object and passes the value to the constructor

Syntax: ClassName objectName(Value/s); Example:MyClass obj(12,13);


Method 2: Explicit Call to constructor

This method creates an object and explicitly invokes the constructor with arguments.

Syntax: ClassName objectName=ClassName(Value/s); Example: MyClass obj=MyClass(12,13);

Method 3: Constructor Call with assignment operator

This method creates an object and assigns only one value to the constructor. This method can be
used in a situation where the constructor initializes a single value.

Syntax: ClassName objectName= Value; Example: MyClass obj=12

Chapter-10: Inheritance
1. Define inheritance, base class and derived class.

Ans) Inheritance is the capability of one class (derived class) to inherit properties from another existing class (base class).
Base Class/Super Class: It is the class whose properties are inherited by another class.

Derived Class/Sub Class: It is the class that inherits the properties from base class.

2. Write the advantages of inheritance.

Ans) Reusing existing code

Faster development time

Easy to maintain

Easy to extend

Memory Utilization

3. Explain the types of inheritance.

Ans)

Single Inheritance :-
Single Inheritance is the process of creating a new class from existing class base class. If a class is
derived from a single base class, it is called as single inheritance Eg:

Multilevel Inheritance: - Derivation of a class from another derived class is called multilevel
inheritance. Example:

Multiple Inheritance: - If a class is derived from more than one base, it is known as multiple
inheritance. Example:

Hierarchical inheritance :- if a number of classes are derived from a single base class, it is called as
hierarchical inheritance. Example:

Hybrid inheritance :- it is a combination of hierarchical and multilevel inheritance.


Example:

Chapter -13: Database Concepts

1. Explain data processing cycle.

Ans)
The way data is processed into an information is called as data processing cycle.
1) Data collection (Gathering data, facts and statistics): This task basically involves finding the origin of Data.
2) Data Input: The input of stored data should be done in a form that is understood by the data processing system.
3) Data Processing:
a. Classification of database
b. Sorting of database
c. Verification
d. Calculation
e. Recording and summarizing
4) Data Storage: Data storage may be on devices such as floppies. hard disk, and tape and so on or a hard copy may be
maintained in files.
5) Data Output: The output of data processing system is in the form of a report. Some of the output can be in the form
of sound, picture.
6) Communication: Computers have communication ability which increases their power. Eg. Email

2. Explain various data types used in DBMS?


Ans) The various datatypes used in DBMS are: -
1. Integer: Hold whole number without fractions.
2. Logical: Store data that has only two values true or false.
3. Character(Char): Includes letter, number, spaces, symbols and punctuation. Characters fields or variables store text
information like name, address, but size will be one byte.
4. Strings: Sequence of character more than one.
5. Memo: Stores large amount of alphanumeric data more than 255 characters up to 65,535.
6. Currency: Accepts data in a currency form. The currency data type accepts data in dollar form by default.
7. Date: Accepts data entered in date format

3.Explain the features of DBMS.


Ans) The features of DBMS are:-

1. CENTRALIZED DATA MANAGEMENT: DBMS provides centralized data management.

2. DATA INTEGRITY: It refers to the reliability of the data in the database.

3. DATA SHARING: The data stored in the database can be shared among multiple users of the database.

4. MULTIPLE USER INTERFACES (Multi-user Access): The query language provided by DBMS is so easy to understand.

5. BACKUP AND RECOVERY: for recovery from hardware and software failures.

4. Mention the application of database.


Ans) The applications of database are
1. Banking: For customer information, accounts and loans, and banking transactions.
2. Water meter billing
3. Rail and Airlines: Reservation and Schedule information.
4. Colleges: Student admission, student information.
5. Finance

5. Give the difference between Manual and Electronic file system.

6. Define database term: a) File b) Database c) Table d) Tuple/Record e) Attribute/Field f) Domain

g) Entity
Ans) a) File- Basic unit of storage in computer system which contains large collection of data.
b) Database- Collection (group) of logically related organized data that can be easily accessed, managed and updated.
c)Table- collection of data elements organized in terms of rows and columns.
d) Tuple/Record/Row- Single entry in a table.
e) Attribute/Field/Column: Each Column is identified by a distinct header called attribute or field.
f) Domain is a set of all unique values permitted for an attribute in that column.
g) Entity is a person, a place, or a thing for which data is collected and maintained .

7. Explain database users.


Ans) Application programmers and System Analysts – These users write application programs to interact with the
database.
End users - End users use the developed applications.
Database Administrator (DBA) - DBA is a person responsible for the overall control of the database. He assigns
privileges and access to different users.
Database designers – they are responsible for identifying the data to be stored in the database.
8. Explain hierarchical data model.

Ans) Hierarchical Data Model:- It uses tree structures to represent relationship among records. The entities in this model are related in one-to-many relationships. For
example, a college has a number of courses to offer. Each course has a number of students registered for it.

9. Explain relational data model.


Ans) Unlike the hierarchical and network models, there are no physical links. Data is organized in two -dimensional tables called relations. The tables are related to each
other. All data is maintained in the form of tables consisting of rows and columns. Each row represents an entity and a column represents an attribute of the entity

10. Define file organization. Explain its types.

Ans) File organization explains the way in which records are arranged and accessed.
Serial File Organization:- The collection of data records are stored in the chronological(time of creation) order in the physical medium. No particular sequence is followed to
store the data.

Sequential File Organization:- The data records are stored one after another in an ascending or descending order when file is created.

Chapter-14: SQL Commands

1. Mention the dialects of SQL.

Ans)

2. Explain data types in SQL.


Ans)
1. NUMBER: Used to store a numeric value (decimal, integer or a real value) in a field/column.
Syntax: NUMBER(n,d) (n=no. of digits) & (d=no. of decimal digits)
Example: marks NUMBER(3), NUMBER(5,2).
2. CHAR: Used to store character type data in a column. max character size is 255.
Syntax: CHAR(size)
Example: name CHAR(20)
3. VARCHAR/VARCHAR2: Used to store variable length alphanumeric data.
Syntax: VARCHAR(size)/VARCHAR2(size) max 2000 characters.
Example: address VARCHAR2(30)
4. DATE: Used to store date (DD-MM-YY ) in a column.
Example: dob DATE
5. TIME: Used to store time.
6. LONG: Used to store variable length strings of up to 2 GB size.
Example: description LONG
7. RAW/LONG RAW: Used to store binary data (images/ pictures/ animation/clips etc.)

3. Explain relational and logical operators in SQL.

Ans) (Next Page)


RELATIONAL /COMPARISON OPERATORS:
1)= equals to - checks if the values of two operands are equal or not, condition is true if they are equal
2) != or <> not equals to - checks if the values of two operands are equal or not, condition is true if they are not equal
3) > greater than - checks if ‘’left operand > right operand’’ , if yes, condition is true.
4) < less than - checks if ‘’left operand < right operand’’, if yes, condition is true.
5) >= greater than or equal to - checks if ‘‘left operand => right operand’’, if yes, condition is true.
6) <= less than or equal to - checks if ‘’left operand <= right operand’’ , if yes, condition is true
7) !< not less than - checks if ‘‘left operand => right operand’’, if not, condition is true
8) !> not greater than - checks if ‘’left operand <= right operand’’ , if not, condition is true
LOGICAL OPERATORS:
1)ALL: compares a value to all values in another value or set.
2)UNIQUE: searches every row of a specified table for uniqueness (no duplicates)
3)AND: allows the existence of multiple conditions in an SQL statement’s WHERE clause.
4)OR: combines multiple conditions in an SQL statement’s WHERE clause.
5)NOT: reverses the meaning of the logical operator with which it is used. Eg. NOT EXISTS, NOT IN etc.

4. Explain group functions in SQL.

Ans) Group functions are built in SQL functions that operate on group of rows and return one value for the entire group. These functions are :
COUNT() – returns the number of rows in the table that satisfies the condition specified in the WHERE condition. If the WHERE condition is not specified, then the
query returns the total number of rows in the table.
MAX() – returns the maximum value from a column.
MIN() – returns the minimum value from a column.
SUM() – returns the sum of a numeric column.
AVG() – returns the average value of a numeric column.

5. Explain SQL constraints.

Ans)
• Constraints are rules enforced on data columns on table that limit the type of data that can go into a table. This ensures the accuracy and reliability of the data in the
database.
• It could be column level (applied only to one column) or table level (applied to the whole table).
• Constraints can be specified when a table is created with the CREATE TABLE statement or you can use ALTER TABLE statement to create constraints even after the
table is created.
6. Explain DDL commands with syntax and example.

Ans)
1. CREATE: Creates a new table, a view of a table, or other object in database.
Syntax:- CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
-------
-------
column_nameN data_type
);
Example:- CREATE TABLE student
(
rno char(8),
name varchar2(30),
combination char(4),
dob date,
fees number(10,2)
);
2. ALTER: Modifies an existing database object, such as a table.
Syntax:- ALTER TABLE table_name ADD/MODIFY/DROP columnname1 datatype, columnname2 datatype,.... ;
Examples:- ALTER TABLE student ADD address VARCHAR2(30));
ALTER TABLE student MODIFY address VARCHAR2(40));
ALTER TABLE student DROP address
3. DROP: Deletes an entire table, a view of a table, or other object in database.
Syntax:- DROP TABLE table_name;
Example:- DROP TABLE student;

7. Explain DML commands with syntax and example.

Ans)
1. INSERT: Creates a record.
Syntax:- INSERT INTO table_name [(column1,column2,....columnN)]
VALUES(value1,value2,....,valueN);
The square brackets indicate that the items inside the brackets are optional.
Example:-INSERT INTO student (rno,combination,fees)
VALUES(‘16S1005’,’PCMC’,27000);
2. UPDATE: Modifies records.
Syntax:- UPDATE table_name
SET column_name=value [,column=value,...] WHERE condition;
Example: UPDATE student SET combination=’PCMC’
WHERE name=’Ashish’
3. DELETE: Deletes records.
Syntax:-DELETE FROM table_name [WHERE condition];
Example: DELETE FROM student WHERE combination=’PCMB’;

You might also like