+ All Categories
Home > Documents > OSS 2marks With Answer

OSS 2marks With Answer

Date post: 21-Apr-2015
Category:
Upload: siva-balan
View: 251 times
Download: 2 times
Share this document with a friend
39
1 Dr.N.G.P. Institute of Technology DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING OPEN SOURCE SOFTWARE Faculty in charge: K.Thamarai Selvi, L/CSE Class: III CSE SEM: 06 UNIT I : INTRODUCTION 1. What is Open source software? Open Source Software is software for which the underlying programming code is available to the users so that they may read it, make changes to it, and build new versions of the software incorporating their changes. There are many types of Open Source Software, mainly differing in the licensing term under which (altered) copies of the source code may (or must be) redistributed. 2. What is the Need of Open Source Systems? • No initial cost • No licensing issues • Openness and Transparency • Speed of Access • Freedom of movement • Portable • Reliable • Stable • Security
Transcript
Page 1: OSS 2marks With Answer

1

Dr.N.G.P. Institute of Technology

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

OPEN SOURCE SOFTWARE

Faculty in charge: K.Thamarai Selvi, L/CSE Class: III CSE SEM: 06

UNIT I : INTRODUCTION

1. What is Open source software?

Open Source Software is software for which the underlying programming

code is available to the users so that they may read it, make changes to it,

and build new versions of the software incorporating their changes. There

are many types of Open Source Software, mainly differing in the licensing

term under which (altered) copies of the source code may (or must be)

redistributed.

2. What is the Need of Open Source Systems?

• No initial cost

• No licensing issues

• Openness and Transparency

• Speed of Access

• Freedom of movement

• Portable

• Reliable

• Stable

• Security

Page 2: OSS 2marks With Answer

2

3. What are the four important factors that led to the development of

open source software?

The following are the four important factors that lead to the development of

Open Source Software:

1. To diminish the high monopoly value of the Proprietary Software

2. To avoid discrimination among persons like developers of the

product and users of the product

3. To enable the user finding and fixing the bugs themselves

4. To allow customers to have control over the products they use and

to redistribute the same with or without modifications.

4. What are the advantages of open source system?

• Lesser hardware costs

• High-quality software

• No vendor lock-in

• Integrated management

• Simple license management

• Lower software costs

• Abundant support

• Scaling and consolidating.

5. Mention some Applications of Open Source Systems?

• Finance

• Educational

• Data Storage and Management

• Games

• Media

• Networking and Internet

• Graphics

6. Give some characteristics of Linux?

It is a Unix-like computer operating system.one of the most prominent

examples of free software and open source development: typically all

underlying source code can be freely modified, used, and redistributed by

anyone.The name "Linux" comes from the Linux kernel, started in 1991 by

Linus Torvalds.

Pdominantly known for its use in servers.upported by corporations

such as Dell, Hewlett-Packard, IBM, Novell, Oracle orporation, Red

Hat, and Sun Microsystems sed as an operating system for a wide variety

of computer hardware, including esktop computers, supercomputers, video

Page 3: OSS 2marks With Answer

3

game systems, such as the layStation 2 and PlayStation 3, several arcade

games, and embedded devices uch as mobile phones, routers, wristwatches,

and stage lighting systems

7. What are the two phases in the evolution of Linux?

A Development Phase:

Here the Kernel is not reliable and the Process is to add functionality to it,

Optimize it and to try new ideas. This Phase gives rise to odd-numbered

version

numbers, such as 1.1,1.3 etc., This is the time when the maximum amount of

work is done on the kernel

A Stabilization Phase:

where the aim is to produce as stable a kernel as possible. Only minor

adjustments and modifications are made. The version numbers of so called

Stable Kernels are even, such as 1.0,1.2 etc.,

8. What are the advantages of Linux?

• Low-Cost

• Runs on old Hardware

• Choice

• Installation and GUI

• Security

• Open source

9. List the disadvantages of Linux

• Learning

• Lack of equivalent programs

• More technical ability needed

• Not all hardware compatible

10. What are the types of system?

Operating system is a generic term which in fact describes several families

of systems

Single task system: Only one program may be run at a time, and therefore

only one person may work on a machine at one time. However, the process

may make use of the whole of the resources and power of the machine

Multi task system: Several Processes can be executed in parallel. Operating

time is cut up into small intervals and each process is executed during these

short periods.

Page 4: OSS 2marks With Answer

4

11. What are the roles of an operating system?

• Virtual Machine:

• Sharing the Processor:

• Memory Management:

• Resource management:

• Communication hub of the machine:

12. Define Kernel mode and user mode

The kernel is a privileged mode, in which no restriction is imposed on the

kernel of the system. The kernel may use all the instructions of the

processor, manipulate the whole of the memory, and talk directly to the

peripheral controllers. The user mode is the normal execution mode for a

process. In this mode, the process has no privilege.

13. Define Process and differentiate process and program

A process can be considered to be a program being run. A program is not a

process of itself; it is a passive entity while the process is a active entity with

a program counter specifying the next instruction to be carries out, as well as

the total associated resource.

14. What are the Process states?

During the course of execution, processes change state. The state of a

process is defined by its current activity. The different possible states of a

process are the following

In execution: the process is being executed by the processor,

Ready: the process could be executed, but another process is currently being

executed

Suspended: the process is waiting for a resource

Stopped: the process has been suspended by the external process

Zombie: the process has finished its execution but it is still referenced in the

system

Page 5: OSS 2marks With Answer

5

15. Draw the process state diagram

16. What are the attributes of the process?

During execution, a process is characterized by several attributes maintained

by the system:

• Its state

• Its identification

• The values of the registers, including the program counter

• The user identity whose name the process is executing

• The information used by the kernel to establish the schedule of the

processes

• Information concerning the address space of the process

• Information concerning the inputs/outputs carried out by the process

• Compatibility information summarizing the resources used by the process

17. What are the types of Process Identifiers

• Identification of the real user

• Identification of the effective user

• Identification of the real group

• Identification of the effective group

• A list of group identifiers

18. Define session

A session is a collection of one or more groups of processes. Each session is

assigned to a single control terminal. This terminal is either a peripheral

device or a pseudo-device

Page 6: OSS 2marks With Answer

6

19. Define Scheduler

The scheduler is the kernel function which decides which process should be

executed by the processor: the scheduler scans the list of processes in the

‘ready’ tate, and uses several criteria to choose which process to execute.

20. What are the different scheduling policies in Linux

The Linux scheduler has three different scheduling policies: one for

‘normal’ Processes, and two for ‘real time’ processes

_ SCHED_FIFO, for a unalterable ‘real time’ process.

_ SCHED_RR, for an alterable ‘real time’ process,

_ SCHED_OTHER, for a ‘classical’ process.

21. Define Personality

In order to allow programs coming from other operating system to be run in

Linux, Linux supports the idea of personalities. Each process is assigned to

an execution domain. This domain specifies the way in which system calls

are carried out, and the way in which messages are processed.

22. What a personality defines?

• System calls: Linux uses software interrupts to change into kernel mode,

whilst other Unix system use an inter- segment jump.

• Message number specified by processes: When a process specifies a

message number, for example in calling the primitive sigaction or kill, the

message number is converted by means of look-up-table

• Number of messages sent to processes: when a message is to be sent to a

Process, the message number is converted by means of look-up-table.

23. What is the system call available to change the personality?

The system call personality allows a process to modify its execution domain

in order hat Linux can emulate the behavior of another operating system.

int personality(int pers);

24. Define Clone process

A clone process is created, using primitive type clone, by duplicating its

parent process. But, unlike classical processes, it may share its context with

its parent.

25. Give the system call for cloning

The standard form of the clone function is as follows:

int clone(int (*fn)(), void *child stack, int flag, int nargs,…);

Page 7: OSS 2marks With Answer

7

The parameter fn is the pointer from the child process to the function to be

executed.The parameter child_stack is the pointer to the zone of memory

allocated for thestack of child process.

The parameter Flags defines method for cloning

The parameter Nargs defines the number of arguments to be passed to the

functionpointed by fn and is followed by these arguments

26. Define Signal

It allows processes to react to events triggered by themselves, or by other

processes.Each signal corresponds to a particular event.A signal is

represented in the system by a name of the form SIGXX.The total number of

signals existing in the system is marked by the constant NSIGdefined in the

header file <signal.h>

27. What are the ways in which signal can be generated?

A signal may be generated in several ways, such as:

The signal is the result of particular physical circumstance: When a process

writes to a non allocated zone of memory , there is an invalid access to a

page of memory, which raise a flag. This flag is recognized in the kernel,

whichgenerates a SIGSEGV signal which in turn is sent to the process at

fault. It is the result of terminal user typing CTRL-C. This generates the

signal SIGINTfor which the default action is to terminate the process in the

session foreground. It is the result of system call kill or of command of the

same name which allows the signal to be sent to a selected process.

It is the result of event under the control of the kernel.

28. What are the various actions a process may take upon receiving a

signal?

There are various actions a process may take upon receiving a signal, and

three different defaults:

ignore the signal:

terminate the program;

terminate the program and generate a file core

.

29. What are the list of signal available?

• Terminating and suspending Process

• Physical circumstances

• Available for the Programmer

• Signal Generated by system when Pipe is closed

Page 8: OSS 2marks With Answer

8

• Control of activity

• Linked to the resource

• Management of input and output

• Fault in power supply

30. What is the system call available to send a signal?

The system call Kill is used to send a signal to a process or a group of

processes.

int kill( pid_t pid, int sig);

This returns 0 on no error and -1 on error

Sig- signal t be sent

Pid - identity of the receiving entity

If pid=positive, the signal sig is sent to the process identified by pid

If pid=NULL, the signal sig is sent to the sender group of the sender

If pid=-1 the signal sig is sent to all process except the first

If pid<-1 the signal sig is sent to a group of process identified by pid

To sent a signal to group of processes, there is also the call killpg

int killpg(int pgrp, int sig)

This returns null if it is sent to the group

Pgrp- represents the group the signal is sent to.

To sent signal to itself

int raise(int sig);- in the event of error it sends a non zero value

31. List some of the GNU tools

• gcc ,Debugger,Strace and Make

32. What are the formats supported in Linux for executable programs

Linux supports two formats for executable programs

a.out-binary format

ELF – dynamic libraries

33. Define Library and its types

Libraries constitute a simple meaning of gathering several object files

together Static: during link editing, the library code is integrated with the

executable code Dynamic: the library code is loaded when program is

executed`

Page 9: OSS 2marks With Answer

9

UNIT II : OPEN SOURCE DATABASE

1. What is MySQL?

MySQL is a relational database management system which has 11 million

installations.

It can be used for both Windows and Linux. Managing database includes

adding, accessing, and processing data in a database.

2. Why do so many organizations use MySQL?

Advantages:

• Highly efficient

• Open source

• Highly secured since All password traffic is encrypted connecting to a

server.

• Offers a high scalability in terms of size and connectivity.

3. What is "mysqld"?

mysqld is a daemon server program typically used to start and stop mysql

server. It runs in the background

4. How can you connect to the MySQL Server?

In order to connect to the MySQL server, it is required to give the username

and password. So this can be done with the following

% mysql –h localhost –p –u root

-h localhost to connect to the MySQL server running on the local host

-p to tell mysql to prompt for a password

-u root to connect as the MySQL root user

5. How can you Start MySQL Server?

To start the mysql program type its name in the command- line prompt.

After starting themysql program just display a welcome message using the

following Syntax:

% mysql

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 18427 to server version: 3.23.51-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

Page 10: OSS 2marks With Answer

10

6. How can you terminate the MySQL Server?

Typing the following in Command prompt will shut down the server

completely as root

user

% mysqladmin -u root -p shutdown

7. Explain the tools that are available for managing MySQL Server.

Following are the tools to manage MySQL server:

• mysqld - MySQL server daemon. It is used to start the mysql server.

• mysqladmin – Used to perform administrative tasks.

• mysql - A command-line interface for end users to manage user data

objects.

• mysqlcheck - A command-line interface for administrators to check and

repair tables.

• mysqlshow - A command-line interface for end users to see information

on tables and columns.

• mysqldump - A command-line interface for administrators or end users to

export data from the server to files.

• mysqlimport - A command-line interface for administrators or end users

to load data files into tables program tool to load data into tables.

8. What are the capabilities provided by MySQL client APIs?

• Connecting to the MySQL server; selecting a database; disconnecting

from the server.

• Checking for errors.

• Issuing queries and retrieving results.

• Using prepared statements and placeholders in queries.

• Including special characters and NULL values in queries.

• Handling NULL values in result sets.

9. What are the three fundamental operations that are common to

MySQLPrograms?

• Establishing a connection to the MySQL server.

• Selecting a database.

• Disconnecting from the server

Page 11: OSS 2marks With Answer

11

10. What is difference between mysql_connect and mysql_pconnect?

Mysql_connect() opens a new connection to the database while

mysql_pconnect() opens a persistent connection to the database. This means

that each time the page is loaded

mysql_pconnect() does not open the database. Mysql_close() cannot be used

to close the persistent connection. Though it can be used to close

mysql_connect().

11. What are the two ways in which Warnings can be suppressed in

PHP?

• First, to prevent an individual function call from producing an error

message, put the @ warning suppression operator in front of its name.

• Disable these warnings globally by using the error_reporting( ) function to

set the PHP error level to zero: error_reporting(0)

12. What are the categories of SQL Statements?

• Statements that do not return a result set. This statement category includes

INSERT, DELETE, and UPDATE.

• Statements that return a result set, such as SELECT, SHOW, EXPLAIN,

and DESCRIBE.

13. What are the differences between MySQL_fetch_array(),

MySQL_fetch_object(), MySQL_fetch_row()?

Mysql_fetch_object returns the result from the database as objects while

mysql_fetch_array returns result as an array. This will allow access to the

data by the field names. E.g. using mysql_fetch_object field can be accessed

as $result->name and using mysql_fetch_array field can be accessed as

$result->[name].

mysql_fetch_row($result):- where $result is the result resource returned

from a successful query executed using the mysql_query() function.

Example:

$result = mysql_query(―SELECT * from students);

while($row = mysql_fetch_row($result))

{

Some statement;

}

Page 12: OSS 2marks With Answer

12

14. What are the two types of methods for retrieving rows in Python?

• Fetchone()- Returns the next row as a sequence

• Fetchall()- Returns the entire result set as a sequence of sequences

15. What are the benefits of prepared statements and placeholders

Parameter binding operations automatically handle escaping of characters

Encourage Statement reuse

Easier to read

16. What are the ways of obtaining the connection parameters?

• Hardwire the parameters into the program.

• Ask for the parameters interactively.

• Get the parameters from the command line.

• Get the parameters from the execution environment.

• Get the parameters from a separate file.

• Use a combination of methods.

17. What are the various ways in which SELECT statement can be used

for record selection Technology?

SELECT gives you control over several aspects of record retrieval:

• Which table to use

• Which columns to display from the table

• What names to give the columns

• Which rows to retrieve from the table

• How to sort the rows

18. What is the keyword which can be used to combine column values?

Give Eg.

Column values may be combined to produce composite output values using

the CONCAT () Keyword.

19. How can you map NULL values to other values while display?

IF( ) and IFNULL( ) keywords are used to do so. They are especially useful

for catching divide-by-zero operations and mapping them onto something

else.

Page 13: OSS 2marks With Answer

13

20. When the LIMIT clause will be used?

LIMIT is used for the following kinds of problems:

1)Answering questions about first or last, largest or smallest

2) Splitting a result set into sections so that you can process it one piece at a

time.

21. What are the advantages of copying records from one table to

another?

1.When an algorithm that modifies a table is used then it is safer to work

with the copy

2.When the original table is large then it takes large time to work with so it

is better to work with the which takes less time

3.The data-loading operations that may be malformed when used with

original table can go with the copy to ensure safety

4.The summary operations when repeatedly done over the original table are

expensive so copy can be used to print the summary which is not

expensive as original table

22. What is the use of creating such tables? How can you create

temporary tables?

When you need a table only for a short time, then you want it to disappear

Automatically you can go to create a temporary table. This is extremely

useful behavior because you need not remember to remove the table

The Temporary tables can be created using the keyword CREATE

TEMPORARY TABLE

23. What are the disadvantages of creating a temporary table?

• If you've already created a temporary table with a given name, attempting

to create a second one with that name results in an error.

• persistent connections – may tend not to drop the temporary table

because the connection is let open for the use of next script

• If a client program automatically reconnects after a dropped connection,

you'll be modifying the original table after the reconnect

24. What are the properties of Strings?

• Strings can be case sensitive (or not), which can affect the outcome of

string operations.

• You can compare entire strings, or just parts of them by extracting

substrings.

Page 14: OSS 2marks With Answer

14

• You can apply pattern-matching operations to look for strings that have a

certain structure.

25. What are the types of Strings?

• A binary string in MySQL is one that MySQL treats as case sensitive in

comparisons.

• A non binary string in MySQL is one that MySQL does not treats as case

sensitive in comparisons.

• For binary strings, the characters A and a are considered different. For

non-binary strings, they're considered the same.

26. Does the MID() acts the same way as SUBSTRING() ? Justify

MID() acts the same way as the SUBSTRING() if the third argument of the

MID() is omitted.

27. What are the ways provided by MySQL for Pattern Matching?

MySQL provides two kinds of pattern matching.

1) One is based on SQL patterns

2) regular expressions.

28. What are the data types supported by MySQL for Date and Time

formats?

MySQL supports a number of date and time column formats: Some of

them are

DATE

DATETIME

TIMESTAMP

29. Give Examples of various type of Date and Time formats.

It is most common to store dates using a dash (-) as the delimiter and a colon

(:)

as the time delimiter. The Following formats can also be used.

2008-10-23 10:37:22

20081023103722

2008/10/23 10.37.22

2008*10*23*10*37*22

30. Why do you go for sorting your query results?

SQL SELECT command to fetch data from MySQL table. When you select

Page 15: OSS 2marks With Answer

15

rows, the MySQL server is free to return them in any order, unless you

instruct it otherwise by saying how to sort the result. But you sort a result set

by adding an ORDER BY clause that names the column or columns you

want to sort by.

31. Define Aggregate functions and what are aggregate functions

supported by the MySQL

To compute a summary value from a set of individual values, use one of the

functions known as aggregate functions. These are so called because they

operate on aggregates (groups) of values.

Aggregate functions include COUNT( ), which counts records or values in a

query result; MIN( ) and MAX( ), which find smallest and largest values;

and SUM( ) and AVG( ), which produce sums and means of values.

32. What are the types of information available in MySQL?

Information about the result of queries: This includes number of records

effected by any SELECT, UPDATE or DELETE statement.

Information about tables and databases: This includes information

pertaining to the structure of tables and databases.

Information about the MySQL server: This includes current status of

database server, version number etc

33. Define Sequence

A sequence is a set of integers 1, 2, 3, ... that are generated in order on

demand. Sequences are frequently used in databases because many

applications require each row in a table to contain a unique value, and

sequences provide an easy way to generate them

UNIT III : OPEN SOURCE PROGRAMMING LANGUAGES

1. What is PHP?

_ PHP stands for Hypertext Preprocessor and is a server-side language.

_ This means that when a visitor opens the page, the server processes the

PHP commands and then sends the results to the visitor's browser, just as

with ASP.

_ A typical PHP files will content commands to be executed in the server in

addition to the usual mixture of text and HTML (Hypertext Markup

Language)tags. However, PHP is Open Source and cross-platform.

Page 16: OSS 2marks With Answer

16

2. What can PHP do for you?

PHP offers plenty of possibilities:

_ PHP is appropriate whenever you want your pages to be created

dynamically when the browser requests the page. For example, you can

display date, time, and other information in different ways. PHP will make

your website more dynamic in content and a heck of a lot easier to update.

_ PHP makes it easy to customize a Web page to make it more useful for

individual users.

_ With PHP you can set cookies, manage authentication, and redirect users.

_ One of PHP most powerful features is database access. With PHP it is

possible to access over 19 different types of databases and manipulate data

within those databases based on input from the user via a web page.

_ PHP makes it easy to send e-mail, work with newsgroups, and actually

open a connection to another web site -- and get or send data with it. If you

are already familiar with ASP development, PHP can also communicate with

other serverside languages such as Java and use COM interfaces.

3. Define Variable.

_ A variable is a holder for a type of data. So, based on its type, a variable

can hold numbers, strings, booleans, objects, resources or it can be NULL.

_ In PHP all the variables begin with a dollar sign "$" and the value can be

assignes using the "=" operator.

_ The dollar sign is not technically part of the variable name, but it is

required as the first character for the PHP parser to recognize the variable as

such.

4. What are the variable naming conventions in PHP?

_ There are a few rules that you need to follow when choosing a name for

your PHP variables.

_ PHP variables must start with a letter or underscore "_".

_ PHP variables may only be comprised of alpha-numeric characters and

underscores. a-z, A-Z, 0-9, or _ .

_ Variables with more than one word should be separated with underscores:

$my_variable.

_ Variables with more than one word can also be distinguished with

capitalization:

$myVariable.

_ One important thing to note if you are coming from another programming

language there is no size limit for variables.

Page 17: OSS 2marks With Answer

17

5. What are the scope of variables in PHP?

_ The scope of a variable, which is controlled by the location of the

variable’s declaration, determines those parts of the program that can access

it. There are four types of variable scope in PHP:

_ Local - A variable declared in a function is local to that function.

_ global - Variables declared outside a function are global. That is, they can

be accessed from any part of the program.

_ Static - A static variable retains its value between calls to a function but is

visible only within that function.

_ function parameters - Function parameters are local, meaning that they

are available only inside their functions.

6. Define constant and what is the main difference between the variable

and the constant

_ Constants just as variables are used to store information.

_ The main difference between constants and variables is that constant value

can not be changed in the process of running program.

7. What are the data types available in PHP?

_ PHP provides eight types of values, or data types.

_ Four are scalar (single-value) types:

• integers,

• floating-point numbers,

• strings, and

• booleans.

_ Two are compound (collection) types:

• arrays and

• objects.

_ The remaining two are special types:

• resource and

• NULL.

8. Define expressions and operators.

_ An expression is a bit of PHP that can be evaluated to produce a value.

The simplest expressions are literal values and variables.

_ A literal value evaluates to itself, while a variable evaluates to the value

stored in the variable. More complex expressions can be formed using

simple expressions and operators.

_ An operator takes some values (the operands) and does something (for

instance, adds them together).

Page 18: OSS 2marks With Answer

18

9. What are the different types of Operators based on the number of

operands it takes?

_ Most operators in PHP are binary operators; they combine two operands

(or expressions) into a single, more complex expression.

_ PHP also supports a number of unary operators, which convert a single

expression into a more complex expression.

_ Finally, PHP supports a single ternary operator that combines three

expressions into a single expression.

10. Define Operator Precedence ,operator associativity and casting

_ The order in which operators in an expression are evaluated depends on

their relative precedence.

_ Associativity defines the order in which operators with the same order of

precedence are evaluated.

_ The conversion of a value from one type to another is called casting.

11. What are the types of operators available in PHP?

_ The conversion of a value from one type to another is called casting.

• Arithmetic Operators

• String Concatenation Operator

• Auto increment and Auto decrement Operators

• Comparison Operators

• Bitwise Operators

• Logical Operators

• Casting Operators

• Assignment Operators and some miscellaneous Operators

12. What are the flow control statements available in PHP and give the

syntax of each statement?

if

if (expression)

statement

if else

if (expression)

statement

else

statement

switch

switch($name) {

Page 19: OSS 2marks With Answer

19

case 'ktatroe':

// do something

break;

case 'rasmus':

// do something

break;}

while

while (expression)

statement

do/while

do

statement

while (expression)

for

for (start; condition; increment)

statement

foreach

foreach ($array as $current) {

// ...

}

declare

declare (directive)

statement

exit and return

13. Define Function

_ A function is a named block of code that performs a specific task, possibly

acting upon a set of values given to it, or parameters, and possibly returning

a single value.

14. Give the syntax to call a function

_ $some_value = function_name( [ parameter, ... ] );

_

15. Give the syntax to define a function

_ To define a function, use the following syntax:

function [&] function_name ( [ parameter [, ... ] ] )

{

statement list

}

Page 20: OSS 2marks With Answer

20

16. What are the types to pass parameters to the function?

There are two different ways of passing parameters to a function.

– The first, and more common, is by value.

– The other is by reference.

17. Define Passing parameters by values and reference

_ When a parameter is passed by value, the compiler passes the actual value

to the called procedure. When a parameter is passed by value, the called

program or procedure can change the value of the parameter, but the caller

will never see the changed value

_ Passing parameters by reference to a procedure allows the callee to modify

the field passed.

18. What is the Drawback of returning the reference?

_ The drawback of returning the reference is that it is slower than returning

the value and relying on the shallow-copy mechanism to ensure that a copy

of that data is not made unless it is changed.

19. Define array in PHP

_ An array is a special variable, which can store multiple values in one

single variable.

_ Arrays can be used in many ways to store and organize data quickly and

efficiently. It is one of the more useful data types available to any

programming language.

_ Arrays can most easily be described as an ordered list of elements.

20. How can you assign a range of values to the array?

_ The range( ) function creates an array of consecutive integer or character

values between the two values you pass to it as arguments.

For example:

$numbers = range(2, 5); // $numbers = array(2, 3, 4, 5);

$letters = range('a', 'z'); // $letters holds the alphabet

$reversed_numbers = range(5, 2); // $reversed_numbers = array(5, 4, 3, 2);

Page 21: OSS 2marks With Answer

21

21. How can you get the size of the array?

_ The count( ) and sizeof( ) functions are identical in use and effect. They

return the number of elements in the array. There is no stylistic preference

about which function you use.

$family = array('Fred', 'Wilma', 'Pebbles');

$size = count($family); // $size is 3

22. What are the functions available to sort an array?

Sorting numerically indexed arrays

_ The sort() function orders the array element in ascending order.

Sorting associative arrays

_ The asort() function orders the array according to the value of each

element in ascending order.

_ we use ksort() function to sort an associative array according to the key in

ascending order.

Sorting arrays in the reverse order

_ Rsort() function sorts one-dimensional numerically indexed array by the

values in reverse order.

_ Arsort() function sorts one-dimensional associative array by the values in

reverse order.

_ Krsort() function sorts one-dimensional associative array by the keys in

reverse order.

23. What is OOP?

_ OOP stands for Object Oriented Programming. OOP is a programming

paradigm wherein you create "objects" to work with. These objects can then

be tailored to your specific needs, to serve different types of applications

while maintaining the same code base. Quite useful indeed.

24. What is an object and class?

_ An object is simply a copy or instance of a "class".

_ A class can be defined as a "black box" from where we create our objects

and access its attributes (variables) and methods (functions).

25. Define Polymorphism

_ Polymorphism is an OOP characteristic that allows the programmer to

assign a different meaning or usage to something in different contexts -

Page 22: OSS 2marks With Answer

22

specifically, to allow a class member to perform different tasks depending

on the context it was used.

26. Define Inheritance

_ The basic idea behind inheritance is that similar objects share common

properties. So by creating a "generic" class, we can have a blueprint to build

our subsequent classes on.

27. What are the levels of visibility?

_ Public: means that a class member is visible and usable / modifiable by

everyone

_ Private: means that a class member is only usable / modifiable by the

class itself

_ Protected: means that a class member is only usable / modifiable by the

class itself and eventual sub-classes

28. What are the functions available to search a string?

_ strpos() - The way strpos works is it takes some string you want to search

in as its first argument and another string, which is what you are actually

searching for, as the second argument.

$pos = strpos($mystring, $findme);

_ str_replace() - The str_replace function is similar to a word processor's

"Replace All" command

str_replace(search, replace, originalString).

_ substr_replace() - The function substr_replace introduces some additional

functionality to compliment str_replace. substr_replace is a more

mathematically based replace function, which relies on starting points and

lengths to replace parts of strings, as opposed to searching and replacing.

substr_replace(original string, replacement string, starting

point)

29. What are the capitalization functions available in PHP?

_ PHP has three primary capitalization related functions:

• strtoupper

• strtolower and

• ucwords.

_ The function names are pretty self-explanatory

Page 23: OSS 2marks With Answer

23

30. Define Regular Expression and what are the regular expressions

supported by PHP

_ A regular expression is a string that represents a pattern. The regular

expression functions compare that pattern to another string and see if any of

the string matches the pattern.

_ PHP provides support for two different types of regular expressions:

• POSIX

• Perl compatible.

31. What are the three uses of regular expressions

• matching, which can also be used to extract information from a string;

• substituting new text for matching text;

• splitting a string into an array of smaller chunks.

32. What are the three basic types of abstract patterns in a regular

expression?

_ A set of acceptable characters that can appear in the string (e.g.,

alphabetic characters, numeric characters, specific punctuation characters)

_ A set of alternatives for the string (e.g., "com", "edu", "net", or "org")

_ A repeating sequence in the string (e.g., at least one but no more than five

numeric characters)

_ A set of acceptable characters that can appear in the string (e.g.,

alphabetic characters, numeric characters, specific punctuation characters)

_ A set of alternatives for the string (e.g., "com", "edu", "net", or "org")

_ A repeating sequence in the string (e.g., at least one but no more than five

numeric characters)

33. Define anchor and Quantifier

_ An anchor limits a match to a particular location in the string (anchors do

not match actual characters in the target string).

_ The quantifier goes after the pattern that’s repeated and says how many

times to repeat that pattern.

34. Define Greedy and Non greedy quantifier

_ when faced with a quantifier, the engine matches as much as it can while

still satisfying the rest of the pattern.-Greedy

_ Quantifiers that match as few times as possible to satisfy the rest of the

pattern- Non Greedy

Page 24: OSS 2marks With Answer

24

35. What is a file?

_ A file is a sequence of bytes stored persistently on a physical medium like

a hard disk. Each file is uniquely identified by its absolute path.

36. Mention the advantages of simple text file system

1) Minimization of cost. Cost of maintaining databases like Oracle are huge,

thus files are low cost answer to these databases.

2) Taking back Up of your database is very easy. All you have to do is to

copy the file.

3) It much easier to transfer a text file from one OS to another.

37. Mention the disadvantages of simple text file system

1) Text files do not support SQL Query languages. Thus you will have to

code your data retrieval and updation algorithms yourself.

2) It does not use any indexing mechanism , thus searching mechanism is

much slower.

3) You cannot use triggers, define primary keys , Foreign Keys etc.

38. How can you open a file?

_ The fopen() function can be used to open any file in the server's file

system.

int fopen(string filename, string mode [, string use_include_path])

39. How can you close a file?

int fclose(int fp)

_ The fclose() function is used to close an opened file. The argument fp is

the file pointer of the file to be closed.

40. What are the functions available to read a file?

_ string fread(int fp, int length)

_ string fgetc(int fp)

_ string fgets(int fp, int length)

_ string fgetss(int fp, int length [,string allowable_tags])

_ array file(string filename [,int use_include_path])

41. What are the functions available to write contents to a file?

_ int fputs(int fp, string stringtoWrite [,int length]);

_ int fwrite(int fp, string stringtoWrite [,int length]);

Page 25: OSS 2marks With Answer

25

42. What are the functions available to display a file?

_ int fpassthru(int fp)

_ int readfile(string filename)

43. What are the functions available to navigate within a file?

_ int rewind(int fp)

_ int fseek(int fp, int offset [, int whence])

_ int ftell(int fp)

_ int feof(int fp)

44. What are the functions available to copy , rename and delete a file?

_ int copy(string source, string destination)

_ int rename(string oldname, string newname)

_ int unlink(string filename)

45. What are the functions available to determine the attributes of a

file?

_ int file_exists(string filename)

_ int fileatime(string filename)

_ int filectime(string filename)

_ int filemtime(string filename)

_ int filesize(string filename)

_ string filetype(string filename)

46. What are the three places where the data can be stored in PHP?

• flat file

• session variables

• cookies.

47. Define flat files and mention its advantages over databases

_ Flat files are text files stored in the computer file system. Humans can read

flat files by using the operating system commands that display files, such as

cat in Linux and Unix.

_ Flat files have some advantages over databases:

• Available and versatile: You can create and save data in any operating

system's file system. You don't need to install any extra software.

Additionally, text data stored in flat files can be read by a variety of

software programs, such as word processors or spreadsheets.

• Easy to use: You don't need to do any extra preparation, such as install

database software, design a database, create a database, and so on. Just

Page 26: OSS 2marks With Answer

26

create the file and store the data with statements in your PHP script.

• Smaller: Flat files store data by using less disk space than databases.

48. What are the components of LDAP?

_ LDAP data organization, defines how the data is formatted while in

storage and exchange with respect to the communicating LDAP entities, that

is, client-server and server-server

_ LDAP server is the server that LDAP clients interact with to obtain

directory information.

_ LDAP protocol, is the common language spoken by clients and servers

when the clients access the directory

_ LDAP clients implemented using different vendor APIs and tools on

different platforms are able to connect to the LDAP server, as long as they

speak the LDAP protocol and handle data in the particular format required

by LDAP.

49. List out the characteristics of LDAP

_ Global Directory Service

_ Open Standard Interconnectivity

_ Customizability and Extensibility

_ Heterogeneous Data Store

_ Secure and Access Controlled Protocol

50. List out the various models of LDAP

_ Information model

_ Naming model

_ Functional model

_ Security model

51. What are the various PHP's LDAP client functions?

The various PHP's LDAP client functions:

_ Connection and control functions

_ Search functions

_ Modification functions

_ Error functions

Page 27: OSS 2marks With Answer

27

52.What are the different error handling methods in PHP?

The different error handling methods:

• Simple "die()" statements

• Custom errors and error triggers, Error reporting

53. Give the Importance of PHP Seurity

_ PHP is widely used language for web applications

_ PHP is making headway into enterprise as well as corporate markets

_ Most effective and often overlooked measure to prevent malicious users

_ PHP applications often end up working with sensitive data

54. What are the concerns of PHP security?

_ Register Globals

_ SQL Injection

_ Cross Site Scripting

_ User login systems

55. Define Template

A template is an HTML-like document that defines the presentation of a

web page, while a PHP script supplies the content. The separation of content

and presentation is at the heart of any GUI paradigm.

UNIT IV : PYTHON

1. Give some of the rules and certain symbols used with regard to

statements

in Python

Hash mark ( # ) indicates Python comments

NEWLINE ( \n ) is the standard line separator (one statement per line)

Backslash ( \ ) continues a line

Semicolon ( ; ) joins two statements on a line

Colon ( : ) separates a header line from its suite

Statements (code blocks) grouped as suites

Suites delimited via indentation

Python files organized as "modules"

2. Give the module structure and layout of python programming

# (1) startup line (Unix)

# (2) module documentation

Page 28: OSS 2marks With Answer

28

# (3) module imports

# (4) variable declarations

# (5) class declarations

# (6) function declarations

# (7) "main" body

3. Give the characteristics of Python objects

Identity

Unique identifier that differentiates an object from all others.

Type

An object's type indicates

what kind of values an object can hold,

what operations can be applied to such objects, and

what behavioral rules these objects are subject to.

Value

Data item that is represented by an object.

4. What are the standard types present in python programming

Numbers (four separate sub-types)

Regular or "Plain" Integer

Boolean

Long Integer

Floating Point Real Number

Complex Number

String

List

Tuple

Dictionary

5. What are the built in types present in python programming

Some other built in types are

Type

Null object(None)

File

Set/Frozenset

Function/Method

Module

Class

Page 29: OSS 2marks With Answer

29

6. What are the internal types present in python programming

The following internal types are in python programming

Code

Frame

Traceback

Slice

Ellipsis

Xrange

7. What are the types of numbers present in python

Python has four types of numbers:

"plain" integers,

long integers,

floating point real numbers, and

complex numbers.

8. How to Create and Assign Numbers (Number Objects)

Creating numbers is as simple as assigning a value to a variable:

anInt = 1

aLong = -9999999999999999L

aFloat = 3.1415926535897932384626433832795

aComplex = 1.23 + 4.56J

9. How to Update Numbers

You can "update" an existing number by (re)assigning a variable to another

number. The new value can be related to its previous value or to a

completely different number altogether.

anInt = anInt + 1

aFloat = 2.718281828

10. How to Remove Numbers

Under normal circumstances, you do not really "remove" a number; you just

stop using it! If you really want to delete a reference to a number object, just

use the del statement

del anInt

del aLong, aFloat, aComplex

Page 30: OSS 2marks With Answer

30

11. Define sequence

Sequence types all share the same access model: ordered set with

sequentially indexed offsets to get to each element.

The numbering scheme used starts from zero (0) and ends with one less the

length of the sequence.

12. How can you access elements using slice operator?

The syntax for accessing an individual element is:

sequence[index]

The syntax for accessing a group of elements is:

sequence [ [starting_index]: [ending_index]]

13. How to Create and Assign Strings

Creating strings is as simple as assigning a value to a variable:

>>> aString = 'Hello World!'

>>> print aString

Hello World!

>>> aBlankString = ''

>>> print aBlankString

''

14. How to Access Values(Characters and Substrings) in Strings

Python does not support a character type; these are treated as strings of

length one, thus also considered a substring. To access substrings, use the

square brackets for slicing along with the index or indices to obtain your

substring:

>>> aString = 'Hello World!'

>>> aString[0]

'H'

>>> aString[1:5]

'ello'

>>> aString[6:]

'World!'

15. How to Update Strings

You can "update" an existing string by (re)assigning a variable to another

string. The new Value can be related to its previous value or to a completely

different string altogether.

>>> aString = aString[:6] + 'Python!'

>>> aString

Page 31: OSS 2marks With Answer

31

'Hello Python!'

Like numbers, strings are not mutable, so you cannot change an existing

string without creating a new one from scratch. That means that you cannot

update individual characters or substrings in a string.

16. How to Remove Characters and Strings

To repeat what we just said, strings are immutable, so you cannot remove

individual characters from an existing string. What you can do, however, is

to empty the string, or to put together another string which drops the pieces

you were not interested in.

>>> aString = 'Hello World!'

>>> aString = aString[:3] + aString[4:]

>>> aString

'Helo World!'

To clear or remove a string, you assign an empty string or use the del

statement, respectively:

>>> aString = ''

>>> aString

''

>>> del aString

In most applications, strings do not need to be explicitly deleted. Rather, the

code defining the string eventually terminates, and the string is automatically

garbage collected.

17. Define raw string operator

The purpose of raw strings, introduced to Python in version 1.5, is to

counteract the behavior of the special escape characters that occur in strings.

In raw strings, all characters are taken verbatim with no translation to special

or non-printed characters. This feature makes raw strings absolutely

convenient when such behavior is desired, such as when composing regular

expressions

18. How to Create and Assign Lists

Creating lists is as simple as assigning a value to a variable. You handcraft a

list (empty or with elements) and perform the assignment. Lists are

delimited by surrounding square brackets ( [ ] ).

>>> aList = [123, 'abc', 4.56, ['inner', 'list'], 7-9j]

>>> print aList

[123, 'abc', 4.56, ['inner', 'list'], (7-9j)]

Page 32: OSS 2marks With Answer

32

19. How to Access Values in Lists

Slicing works similar to strings; use the square bracket slice operator ( [ ] )

along with the index or indices.

>>> aList[0]

123

>>> aList[:3]

[123, 'abc', 4.56]

>>> aList[3][1]

'list'

20. How to Update Lists

You can update single or multiple elements of lists by giving the slice on the

left-hand side of the assignment operator, and you can add to elements in a

list with the append() method:

>>> aList

[123, 'abc', 4.56, ['inner', 'list'], (7-9j)]

>>> aList[2]

4.56

>>> aList[2] = 'float replacer'

>>> aList

[123, 'abc', 'float replacer', ['inner', 'list'], (7-9j)]

>>>

21. How to Remove List Elements and Lists

To remove a list element, you can use either the del statement if you know

exactly which element(s) you are deleting or the remove() method if you do

not know.

>>> aList

[123, 'abc', 'float replacer', ['inner', 'list'], (7-9j)]

>>> del aList[1]

>>> aList

[123, 'float replacer', ['inner', 'list'], (7-9j)]

>>> aList.remove(123)

>>> aList

22. How to Create and Assign Tuples

Creating and assigning lists are practically identical to lists, with the

exception of empty tuples. These require a trailing comma ( , ) enclosed in

the tuple delimiting parentheses ( ( ) ).

>>> aTuple = (123, 'abc', 4.56, ['inner', 'tuple'], 7-9j)

Page 33: OSS 2marks With Answer

33

>>> print aTuple

(123, 'abc', 4.56, ['inner', 'tuple'], (7-9j))

23. How to Access Values in Tuples

Slicing works similar to lists: Use the square bracket slice operator ([ ])

along with the

index or indices.

>>> aTuple>>> aList[1:4]

('abc', 4.56, ['inner', 'tuple'])

>>> aTuple[:3]

(123, 'abc', 4.56)

>>> aTuple[3][1]

'tuple'

24. How to Update Tuples

Like numbers and strings, tuples are immutable which means you cannot

update them or change values of tuple elements. In Sections 6.2 and 6.3.2,

we were able to take portions of an existing string to create a new string. The

same applies for tuples.

>>> aTuple = aTuple[0], aTuple[1], aTuple[-1]

>>> aTuple

(123, 'abc', (7-9j))

>>> tup1 = (12, 34.56)

>>> tup2 = ('abc', 'xyz')

>>> tup3 = tup1 + tup2

>>> tup3

(12, 34.56, 'abc', 'xyz')

25. How to Remove Tuple Elements and Tuples

Removing individual tuple elements is not possible. There is, of course,

nothing wrong with putting together another tuple with the undesired

elements discarded. To explicitly remove an entire list, just use the del

statement:

del aTuple

26. How to Create and Assign Dictionaries

Creating dictionaries simply involves assigning a dictionary to a variable,

regardless of whether the dictionary has elements or not:

>>> dict1 = {}

>>> dict2 = {'name': 'earth', 'port': 80}

Page 34: OSS 2marks With Answer

34

>>> dict1, dict2

({}, {'port': 80, 'name': 'earth'})

27. How to Access Values in Dictionaries

To access dictionary elements, you use the familiar square brackets along

with the key to obtain its value:

>>> dict2['name']

'earth'

>>>

>>> print 'host %s is running on port %d' % \

... (dict2['name'], dict2['port'])

host earth is running on port 80

28. How to Update Dictionaries

You can update a dictionary by adding a new entry or element (i.e., a key-

value pair), modifying an existing entry, or deleting an existing entry (see

below for more details on removing an entry).

>>> dict2['name'] = 'venus' # update existing entry

>>> dict2['port'] = 6969 # update existing entry

>>> dict2['arch'] = 'sunos5' # add new entry

>>>

>>> print 'host %(name)s is running on port %(port)d' % dict2

host venus is running on port 6969

29. How to Remove Dictionary Elements and Dictionaries

del dict1['name'] # remove entry with key 'name'

dict1.clear() # remove all entries in dict1

del dict1 # delete entire dictionary

30. Define dictionary key look up operator

The only operator specific to dictionaries is the key-lookup operator, which

works very similar to the single element slice operator for sequence types.

For a dictionary, lookups are by key, so that is the argument rather than an

index. The key- lookup operator is used for both assigning values to and

retrieving values from a dictionary:

dict[k] = v # set value 'v' in dictionary with key 'k'

dict[k] # lookup value in dictionary with key 'k'

Page 35: OSS 2marks With Answer

35

31. Define pass statement

One Python statement not found in C is the pass statement.

Because Python does not use curly braces to delimit blocks of code, there

are places where code is syntactically required.

We do not have the equivalent empty braces or single semicolon the way C

has to indicate "do nothing."

If you use a Python statement that expects a sub-block of code or suite, and

one is not present, you will get a syntax error condition.

For this reason, we have pass, a statement that does absolutely nothing—it is

a true NOP, to steal the "No OPeration" assembly code jargon

32. List the file built in methods

File methods come in four different categories:

input

output

movement within a file("intra-file motion") and

miscellaneous

33. DefineCommand line arguments

Command-line arguments are those arguments given to the program in

addition to the script name on invocation. Historically, of course, these

arguments are so named because they are given on the command-line along

with the program name in a textbased environment like a Unix- or DOS-

shell.

34. Define Pickling or flattening or serializing or marshelling

Pickling is the process whereby objects more complex than primitive types

can be converted to a binary set of bytes that can be stored or transmitted

across the network, then be converted back to their original object forms.

Pickling is also known as flattening, serializing, or marshalling.

35. What is the function of DBM- Style module and shelve module

The *db* series of modules writes data in the traditional DBM format

The shelve module uses the anydbm module to find a suitable DBM module,

then uses cPickle to perform the pickling process. The shelve module

permits concurrent read access to the database file, but not shared

read/write access.

Page 36: OSS 2marks With Answer

36

36. Define exception

Exceptions can best be described as action that is taken outside of the normal

flow of control because of errors. This action comes in two distinct phases,

the first being the error which causes an exception to occur, and the second

being the detection (and possible resolution) phase.

37. What are the various types of errors in python

NameError: attempt to access an undeclared variable

ZeroDivisionError: division by any numeric zero

SyntaxError: invalid syntax

IndexError: request for an out-of-range index for sequence

KeyError: request for a non-existent dictionary key

IOError: input/output error

AttributeError: attempt to access an unknown object attribute

38. How to detect and handle errors in python

Exceptions can be detected by incorporating them as part of a try statement.

Any code suite of a try statement will be monitored for exceptions.

There are two main forms of the try statement: try-except and try-finally.

try-except statements allow one to detect and handle exceptions.

try-finally statements allow only for detection and processing of any

obligatory clean-up

39. Differentiate function and procedure

Functions are often compared to procedures. Both are entities which can be

invoked, but the traditional function or "black box," perhaps taking some or

no input parameters, performs some amount of processing and concludes by

sending back a return value to the caller. Some functions are Boolean in

nature, returning a "yes" or "no" answer, or, more appropriately, a non-zero

or zero value, respectively. Procedures, often compared to functions, are

simply special cases, functions which do not return a value. Python

procedures are implied functions because the interpreter implicitly returns a

default value of None

40. Define Function Operator

Functions are called using the same pair of parentheses that you are used to.

In fact, some consider ( ( ) ) to be a two-character operator, the function

operator. Any input parameters or arguments must be placed between these

calling parentheses. Parentheses are also used as part of function

declarations to define those arguments.

Page 37: OSS 2marks With Answer

37

41. How function Declaration and Definition are different from other

programming languages

Some programming languages differentiate between function declarations

and function definitions. A function declaration consists of providing the

parser with the function name, and the names (and traditionally the types) of

its arguments, without necessarily giving any lines of code for the function,

which is usually referred to as the function definition.

In languages where there is a distinction, it is usually because the function

definition may belong in a physically different location in the code from the

function declaration. Python does not make a distinction between the two, as

a function clause is made up of a declarative header line which is

immediately followed by its defining suite

42. Define Recursion

A function is recursive if it contains a call to itself. A procedure is recursive

if a new activation can begin before an earlier activation of the same

procedure has ended. In other words, a new invocation of the same function

occurs within that function before it finished. Recursion is used extensively

in language recognition as well as in mathematical applications that use

recursive functions.

43. Define Module

A Module allows you to logically organize your pythin code. When code

gets to be large the tendency is to break it up into organized pieces that can

still interact with one another at a functioning level

44. Define importing

The process of associating attributes from other modules with your module

is called importing

45. Define namespace

A namespace is a mapping of names to objects. The process of adding a

name to namespace consists of binding the identifier to the object.

46. Define Rebinding and Unbinding

The process of changing the mapping of a name is called rebinding and the

process of removing a name is called unbinding

Page 38: OSS 2marks With Answer

38

47. What is name look up

When accessing an attribute, the interpreter must find it in any one of the

three namespaces (local, global and built in). This is called name look up.

48. What are the features of module import

Modules ―executed not loaded

Importing versus loading

Names imported into current namespace

Names imported into importer’s scope

49. What are the built in functions present in python for modules

_import_( )

Globals and locals

Reload_( )

50. Give the syntax for creating a class

class

ClassName:

'class documentation string"

class_suite

51. Give the syntax for creating the instance for the class

>>> class MyClass: # define class

... pass

>>> myInstance = MyClass() # instantiate class

52. How to Create a Subclasses

Derived classes are declared much like their parent class; however, a list of

base classes o inherit from are given after the

class name:

class SubClassName (ParentClass1[, ParentClass2, ...]):

'optional class documentation string'

class_suite

53. Define callable object

Any object that can be invoked with the function () operator. The function

operator is placed immediately following the name of the callable to invoke

it

Page 39: OSS 2marks With Answer

39

54. Define code object

There are other executable objects in python that do not have the ability to

be invoked like callable. These objects are the smaller pieces of the puzzles

that make up executable blocks of code called code object.

55. Define restricted execution and terminating execution

Restricted execution can be facilitated by rexec which can modify the

objects and bastion module which acts as a attribute filter.

A clean execution occurs only when a program runs to completion. The

execution is terminated either by exception handling or cleaner.


Recommended