Top Banner
1 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 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.
35

Open Source Software - Question Bank (Anna University - Coimbatore)

Sep 05, 2014

Download

Documents

Prabhu Easwar
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Open Source Software - Question Bank (Anna University - Coimbatore)

1

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

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.

Page 2: Open Source Software - Question Bank (Anna University - Coimbatore)

2

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?

Linux 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

Predominantly known for its use in servers supported by corporations such as Dell, Hewlett-

Packard, IBM, Novell, Oracle Corporation, Red Hat, and Sun Microsystems.

Used as an operating system for a wide variety of computer hardware, including desktop

computers, supercomputers, video game systems, such as the PlayStation 2 and PlayStation

3, several arcade games, and embedded devices such 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

Page 3: Open Source Software - Question Bank (Anna University - Coimbatore)

3

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.

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 4: Open Source Software - Question Bank (Anna University - Coimbatore)

4

15. 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

16. 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

17. 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

18. 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’ state, and uses several criteria to

choose which process to execute.

19. 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.

20. 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.

Page 5: Open Source Software - Question Bank (Anna University - Coimbatore)

5

21. 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

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

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

Linux can emulate the behavior of another operating system.

int personality(int pers);

23. 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.

24. 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,…);

• 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 the stack of

child process. The parameter Flags defines method for cloning.

• The parameter nargs defines the number of arguments to be passed to the function pointed

by fn and is followed by these arguments

25. 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 NSIG defined in

the header file <signal.h>

Page 6: Open Source Software - Question Bank (Anna University - Coimbatore)

6

26. 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, which generates 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 SIGINT for 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.

27. 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.

28. What are the lists of signal available?

• Terminating and suspending Process

• Physical circumstances

• Available for the Programmer

• Signal Generated by system when Pipe is closed

• Control of activity

• Linked to the resource

• Management of input and output

• Fault in power supply

29. 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

Page 7: Open Source Software - Question Bank (Anna University - Coimbatore)

7

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

30. List some of the GNU tools

• gcc ,Debugger,Strace and Make

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

Linux supports two formats for executable programs

• a.out-binary format

• ELF – dynamic libraries

32. 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 8: Open Source Software - Question Bank (Anna University - Coimbatore)

8

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?

• 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 the

mysql 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>

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

Page 9: Open Source Software - Question Bank (Anna University - Coimbatore)

9

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 MySQL Programs?

• Establishing a connection to the MySQL server.

• Selecting a database.

• Disconnecting from the server

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.

Page 10: Open Source Software - Question Bank (Anna University - Coimbatore)

10

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; }

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

Page 11: Open Source Software - Question Bank (Anna University - Coimbatore)

11

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

Column values may be combined to produce composite output values using the CONCAT() Keyword.

Example:

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.

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?

– When an algorithm that modifies a table is used then it is safer to work with the copy

– 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

– The data-loading operations that may be malformed when used with original table can go

with the copy to ensure safety

– 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

Page 12: Open Source Software - Question Bank (Anna University - Coimbatore)

12

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.

• 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?

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

Page 13: Open Source Software - Question Bank (Anna University - Coimbatore)

13

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

SQL SELECT command to fetch data from MySQL table. When you select 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;

• 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

Page 14: Open Source Software - Question Bank (Anna University - Coimbatore)

14

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.

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 server side 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 assigns 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?

• 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 15: Open Source Software - Question Bank (Anna University - Coimbatore)

15

5. What are the scopes 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 cannot 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.

1) Four are scalar (single-value) types:

• integers,

• floating-point numbers,

• strings, and

• Booleans.

2) Two are compound (collection) types:

• arrays and

• Objects.

3) 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 16: Open Source Software - Question Bank (Anna University - Coimbatore)

16

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. 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.

13. Give the syntax to call a function

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

14. Give the syntax to define a function

To define a function, use the following syntax:

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

{

Statement list

}

Page 17: Open Source Software - Question Bank (Anna University - Coimbatore)

17

15. 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.

16. 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 called to modify the field passed.

17. 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.

18. 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.

19. 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);

20. 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

Page 18: Open Source Software - Question Bank (Anna University - Coimbatore)

18

21. 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.

22. 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.

23. 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).

24. Define Polymorphism

Polymorphism is an OOP characteristic that allows the programmer to assign a different

meaning or usage to something in different contexts - specifically, to allow a class member to

perform different tasks depending on the context it was used.

25. 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.

26. 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

Page 19: Open Source Software - Question Bank (Anna University - Coimbatore)

19

27. 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, startingpoint)

28. What are the capitalization functions available in PHP?

PHP has three primary capitalization related functions:

• strtoupper

• strtolower and

• ucwords.

29. 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.

30. 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.

Page 20: Open Source Software - Question Bank (Anna University - Coimbatore)

20

31. 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)

32. 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.

33. 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

34. 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.

35. 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.

36. 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 updating 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.

Page 21: Open Source Software - Question Bank (Anna University - Coimbatore)

21

37. 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])

38. How can you close a file?

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

int fclose(int fp)

39. 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])

40. 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]);

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

• int fpassthru(int fp)

• int readfile(string filename)

42. 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)

43. 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)

44. 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)

Page 22: Open Source Software - Question Bank (Anna University - Coimbatore)

22

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

• flat file

• session variables

• Cookies.

46. 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 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.

47. 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.

48. List out the characteristics of LDAP

• Global Directory Service

• Open Standard Interconnectivity

• Customizability and Extensibility

• Heterogeneous Data Store

• Secure and Access Controlled Protocol

49. List out the various models of LDAP

• Information model

• Naming model

• Functional model

• Security model

Page 23: Open Source Software - Question Bank (Anna University - Coimbatore)

23

50. 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

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

• Simple "die()" statements

• Custom errors and error triggers, Error reporting

52. Give the Importance of PHP Security

• 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

53. What are the concerns of PHP security?

• Register Global

• SQL Injection

• Cross Site Scripting

• User login systems

54. 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.

Page 24: Open Source Software - Question Bank (Anna University - Coimbatore)

24

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

# (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.

Page 25: Open Source Software - Question Bank (Anna University - Coimbatore)

25

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/Frozen set

• Function/Method

• Module

• Class

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.

Page 26: Open Source Software - Question Bank (Anna University - Coimbatore)

26

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

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

''

Page 27: Open Source Software - Question Bank (Anna University - Coimbatore)

27

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

'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!'

Page 28: Open Source Software - Question Bank (Anna University - Coimbatore)

28

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)]

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'

Page 29: Open Source Software - Question Bank (Anna University - Coimbatore)

29

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)

>>> print aTuple

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

Page 30: Open Source Software - Question Bank (Anna University - Coimbatore)

30

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

Page 31: Open Source Software - Question Bank (Anna University - Coimbatore)

31

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}

>>> 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

>>> 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

Page 32: Open Source Software - Question Bank (Anna University - Coimbatore)

32

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'

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. Define Command 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 text based environment like a Unix- or DOS-

shell.

34. Define Pickling or flattening or serializing or marshalling

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 any dbm 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 33: Open Source Software - Question Bank (Anna University - Coimbatore)

33

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

try-finally.

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 34: Open Source Software - Question Bank (Anna University - Coimbatore)

34

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 python 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 a

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

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

Page 35: Open Source Software - Question Bank (Anna University - Coimbatore)

35

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

to 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

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.