Saturday 11 May 2013

080230027 OPEN SOURCE SOFTWARE QUESTION BANK WITH ANSWERS


UNIT – I
PART-A

1.         Define free software
Generally, the name describes software that is licensed with fewer restrictions than proprietary licensing models, such as "per copy", "per use" object code only licenses. The term "free software" often refers to software that is licensed under the General Public License ("the GPL"). "Free" does not refer to cost, as the GPL does not preclude charging for distribution of licensed software, but rather it refers to the lack of constraints on using the software. However, to prevent intermediates from imposing their own constraints, the GPL includes provisions precluding the addition of constraints.
2.        Is open source software in the public domain?
No. Public domain works are works in which nobody can assert copyright rights. With open source software, the authors, employers or assignees retain the copyright and have the right to sue for copyright infringement, just as with software licensed under proprietary licenses.
3.        State any two differences between Linux and windows.
Linux is an open-source Operating System. People can change codes and add programs to Linux OS which will help use your computer better. But windows is a closed software
Linux has hign security. You have to log on to Linux with a userid and password. You can login as root or as normal user. The root has full privilege. But windows is vulnerable it can be attacked by viruses.
4.        List any two advantages of Linux.
Low cost:
There is no need to spend time and huge amount money to obtain licenses since Linux and much of its software come with the GNU General Public License. There is no need to worry about any software's that you use in Linux.
Stability:
Linux has high stability compared with other operating systems. There is no need to reboot the Linux system to maintain performance levels. Rarely it freeze up or slow down. It has continuous up-times of hundreds of days or more.
Performance:
Linux provides high performance on various networks. It has the ability to handle large numbers of users simultaneously.
Networking:
Linux provides a strong support for network functionality; client and server systems can be easily set up on any computer running Linux. It can perform tasks like network backup faster than other operating systems.
5.        List any two applications of Linux.
•    Linux applications are mostly Cmmercial.
•    Its not user friendly.
6.        What is the Kernel?
A more common definition is that the OS is the one program running at all times on the computer, usually called the kernel, with all else being application programs.

7.        What is an Interactive process in computer system?
Interactive computer system provides direct communication between the user and the system. The user gives instructions to the operating system or to a program directly, using a keyboard or mouse, and waits for immediate results.

8.        What are multiprocessor systems & give their advantages?
Multiprocessor systems also known as parallel systems or tightly coupled systems are systems that have more than one processor in close communication, sharing the computer bus, the clock and sometimes memory & peripheral devices. Their main
advantages are
• Increased throughput
• Economy of scale
• Increased reliability

9.        What are the different types of multiprocessing?
Symmetric multiprocessing (SMP): In SMP each processor runs an identical copy of the Os & these copies communicate with one another as needed. All processors are peers. Examples are WindowsNT, Solaris, Digital UNIX, OS/2 & Linux.
Asymmetric multiprocessing: Each processor is assigned a specific task. A master processor controls the system; the other processors look to the master for instructions or predefined tasks. It defines a master-slave relationship. Example SunOS    Version 4.


10.        What is a process?
A process is a program in execution. It is the unit of work in a modern operating system. A process is an active entity with a program counter specifying the next instructions to execute and a set of associated resources. It also includes the process stack, containing temporary data and a data section containing global variables.

11.        What is a process state and mention the various states of a process?
As a process executes, it changes state. The state of a process is defined in part by the current activity of that process. Each process may be in one of the following states:
• New
• Running
• Waiting
• Ready
• Terminated

12.        Compare user threads and kernel threads.
User threads
User threads are supported above the kernel and are implemented by a thread library at the user level. Thread creation & scheduling are done in the user space, without
Kernel intervention. Therefore they are fast to create and manage blocking system call will cause the entire process to block
Kernel threads
Kernel threads are supported directly by the operating system .Thread creation,
Scheduling and management are done by the operating system. Therefore they are slower to create & manage compared to user threads. If the thread performs a blocking system call, the kernel can schedule another thread in the application for execution.


13.        . What is the usage of JOBS command?
Lists the jobs that you are running in the background and in the foreground. If the prompt is returned with no information no jobs are present. Note: not all shells are capable of running this command.
Syntax
jobs [-p | -l] [-n] [-p] [-x] [job id] 
-p | -l    Report the process group ID and working directory of the jobs.
-n    Display only jobs that have stopped or exited since last notified.
-p    Displays only the process IDs for the process group leaders of the selected jobs.
-x    Replace any job_id found in command or arguments with the corresponding process group ID, and then execute command passing it arguments.
job id    The job id.

14.        What is the use of pg command?
It is  a file related command in linus. It is a Files perusal filters for CRTs.
Syntax
pg [-number] [-p string] [-c] [-e] [-f] [-n] [-r][-s] [+ linenumber] [+/ pattern /] [filename]

15.        What is the use of fg command?
Continues a stopped job by running it in the foreground, some shells are not able to run this command.
Syntax
fg [%job]
%job     Specifies the job that you want to run in the foreground.
Examples
fg
Typing fg alone will resume the first job where it was left off.
fg 1
Specifying the job (in this case 1) will resume that particular job. The job id can be determined by running the bg command.

16.        What is the use of kill command?
It is used to cancel a certain job.
Syntax
kill [-s] [-l] %pid
-s    Specify the signal to send, using one of the symbolic names defined in the <signal.h> description. Values of signal will be recognized in a case independent fashion, without the SIG prefix. In addition, the symbolic name 0 will be recognized, representing the signal value zero. The corresponding signal will be sent instead of SIGTERM.
-l    Write all values of signal supported by the implementation, if no operand is given. Shell special parameter and wait corresponding to a process that was terminated by a signal, the signal corresponding to the signal that terminated the process will be written. If an exit status operand is given and it is the unsigned decimal integer value of a signal number, the signal corresponding to that signal will be written. Otherwise, the results are unspecified.

17.        What is mean by a Daemon’s program?
For simple unix programmers like me, a daemon is just a process that runs in the background, usually waiting for something to happen that it is capable of working with, like a printer daemon is waiting for print commands.

18.        List some of the process attributes.
A process has a series of characteristics:
The process ID or PID: a unique identification number used to refer to the process.
•    The parent process ID or PPID: the number of the process (PID) that started this process.
•    Nice number: the degree of friendliness of this process toward other processes (not to be confused with process priority, which is calculated based on this nice number and recent CPU usage of the process).
•    Terminal or TTY: terminal to which the process is connected.
•    User name of the real and effective user (RUID and EUID): the owner of the process. The real owner is the user issuing the command, the effective user is the one determining access to system resources. RUID and EUID are usually the same, and the process has the same access rights the issuing user would have. An example to clarify this: the browser mozilla in /usr/bin is owned by user root :
19.        What is mean by signals?
Signals are a fundamental method for inter process communication and are used in everything from network servers to media players
20.        . List out the signals used in Linux.
SIGINT    2    Term    Interrupt from keyboard
SIGQUIT    3    Core    Quit from keyboard
SIGILL    4    Core    Illegal Instruction
SIGABRT    6    Core    Abort signal from abort(3)

SIGFPE    8    Core    Floating point exception
SIGKILL    9    Term    Kill signal
SIGSEGV    11    Core    Invalid memory reference
SIGPIPE    13    Term    Broken pipe: write to pipe with no readers
SIGALRM    14    Term    Timer signal from alarm(2)

SIGTERM    15    Term    Termination signal
SIGUSR1    30,10,16    Term    User-defined signal 1
SIGUSR2    31,12,17    Term    User-defined signal 2
SIGCHLD    20,17,18    Ign    Child stopped or terminated
SIGCONT    19,18,25        Continue if stopped
SIGSTOP    17,19,23    Stop    Stop process
SIGTSTP    18,20,24    Stop    Stop typed at tty
SIGTTIN    21,21,26    Stop    tty input for background process

 21.        What is the use of at command?
at and batch read commands from standard input or a specified file which are to be executed at a later time, using the shell set by the user's environment variable SHELL, the user's login shell, or ultimately /bin/sh.
at - executes commands at a specified time.

22.        What is the usage of crontab?
The crontab (cron derives from chronos, Greek for time; tab stands for table) command, found in Unix and Unix-like operating systems, is used to schedule commands to be executed periodically. To see what crontabs are currently running on your system, you can open a terminal and run:
Sudo crontab –l

23.        what is the use of sleep command?
This command is used to pause the current jog for certain amount of time. SUFFIX may be `s' for seconds (the default), `m' for minutes, `h' for hours or `d' for days. Unlike most implementations that require NUMBER be an integer, here NUMBER may be an arbitrary floating point number.
24.        what is the use of nice system call?
This is used to change the priority of a conventional process.
25.        What is meant  by batch processes?
These do not need user interaction, and hence they often run in the background. Since such processes do not need to be very responsive, they are often penalized by the scheduler. Typical batch programs are programming language compilers, database search engines, and scientific computations.

26.        What is meant by real time process?
These have very strong scheduling requirements. Such processes should never be blocked by lower-priority processes, they should have a short response time and, most important, such response time should have a minimum variance. Typical real-time programs are video and sound applications, robot controllers, and programs that collect data from physical sensors.


PART-B
1.        Explain the principle of open source software.
2.        Explain the need of open source software.
3.        Discuss the applications of open source software.
4.        Discuss Linux in detail.
5.        List out the properties of Linux.
6.        Compare Linux and windows.
7.        Explain process in detail.
8.        Explain user mode and kernel mode in detail.
9.        State the types of process along with its attributes.
10.        Explain the life and death of a process
11.        Explain scheduling and its types in detail.
12.        Explain personalities and cloning in detail.
13.        Discuss development with Linux


UNIT II

1.         What is DBMS?

It is a collection of programs that enables user to create and maintain a database. In other words it is general-purpose software that provides the users with the processes of defining, constructing and manipulating the database for various applications.
2.        What are the advantages of DBMS?
1.    Redundancy is controlled.
2.    Unauthorised access is restricted.
3.    Providing multiple user interfaces.
4.    Enforcing integrity constraints.
5.    Providing backup and recovery.
3.        What are the disadvantages in File Processing System?
•    Data redundancy and inconsistency.
•    Difficult in accessing data.
•    Data isolation.
•    Data integrity.
•    Concurrent access is not possible.
•    Security Problems.
4.        What is MySQL? Why do so many organizations use MySQL?
MySQL can be considered as a relational database management system. It can be used for both Windows and Linux. Managing database includes adding, accessing, and processing data in a database.
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.
5.        How many storage types are present in MySQL? Define each in detail?
•    MyISAM – Manages the non transactional tables. It provides full text search searching abilities.
•    Memory storage – Formerly known as the HEAP engine, allows a collection of similar ISAM tables to be handled in a single table.
•    Example storage – Serves as an example that assists in writing new storage engines. You can create tables with this engine, but no data can be stored in them or retrieved from them.
•    CSV storage engine stores data using comma separated values.
•    The BLACKHOLE storage engine accepts but does not store data and retrievals always return an empty set.
•    NDCLUSTER is used to implement tables partitioned over many computers.
6.        Explain SELECT Statement by providing examples for the following.
•    Retrieving Individual Columns
•    Retrieving multiple Columns
•    Retrieving ALL Columns
•    Retrieving Distinct Rows
Select statement allows selecting and retrieving data from tables.
Syntax:
Select * | column_name from table name
Retrieving Individual Columns
Select employee_name from employee Where emp_id > 1
Retrieving multiple Columns
Select employee_firstname, employee_lastname from employee Where emp_id
Retrieving ALL Columns
Select * from employee Where emp_id > 1
Retrieving Distinct Rows
Select disctint mobile_number From employee

7.        State and explain generic SQL syntax of SELECT command along with GROUP BY clause to sort data from MySQL table.
Group By is used along with aggregate functions to group the result-set by one or more columns.
Here, the employees are sorted by employee name.
Example: The query below will display employees along with their salaries.
SELECT employee_name,SUM(salary) FROM employee
GROUP BY employee name.
8.        How do you use ORDER BY clause inside PHP Script.
ORDER BY clause in PHP is used to sort the data in the result set. It sorts data in ascending manner by default. To sort data in descending order, DESC is used.
Example:
<?php
//connect to database
mysql_select_db("my_db", $con);
//Query to list employees ordered by AGE
$result = mysql_query("SELECT * FROM Employee ORDER BY age");
?>

9.        State generic SQL syntax and an example of SELECT command along with LIKE clause to fetch data from MySQL table.
LIKE clause is used for pattern matching. % is used to match any string of any length where as _ allows you to match on a single character.
Syntax:
SELECT * FROM table_name
WHERE column_name like 'pattern%';
Example:
SELECT * FROM employee
WHERE emp_name like 'ma%';

10.        Explain how to sort data by providing examples for the following.
•    Sorting by Multiple Columns
•    Specifying sort direction
Sort data: The ORDER BY clause in MySQL can be used to sort the specified column. Default sorting is ascending.
Sorting by Multiple Columns
SELECT employee_id,salary FROM employee ORDER BY salary
Specifying sort direction
SELECT employee_id,salary FROM employee ORDER BY salary DESC;
State generic SQL syntax and an example of SELECT command along with LIKE clause to fetch data from MySQL table.
LIKE clause is used for pattern matching. % is used to match any string of any length where as _ allows you to match on a single character.
Syntax:
SELECT * FROM table_name
WHERE column_name like 'pattern%';
Example:
SELECT * FROM employee
WHERE emp_name like 'ma%';

11.        Explain the use of Where clause by providing examples for the following.
•    Using Where clause
•    Using the IN operator
•    Using the NOT Operator
•    Using no value, i.e. NULL
Where Clause can be used as a predicate to specify some condition to fetch data.
Using Where clause
Select * from employee Where emp_salary > 1000;
Using the IN operator
SELECT * FROM Persons WHERE LastName IN ('Hansen','Pettersen')
Using the NOT Operator
SELECT * FROM employee WHERE employee_name not in ( 'IBM', 'Hewlett Packard', 'Microsoft');
Using no value, i.e. NULL
Create table employee( Emp_id integer (10) NOT NULL, Emp_name varchar(255), );

12.        In how many ways we can retrieve the data in the result set of MySQL using PHP?
You can do it by 4 Ways
1. mysql_fetch_row.
2. mysql_fetch_array
3. mysql_fetch_object
4. mysql_fetch_assoc
13.        What is the purpose of LIKE operator? Provide examples both using percent sign(%) wildcard and the underscore (_) wildcard.
LIKE: The LIKE operator is used to search for a specified pattern in a column. Example using % : select the employees living in a city that starts with "s" from table employee
SELECT * FROM Persons WHERE City LIKE 's%'
Example using _ : return all employees whose name is 5 characters long, where the first two characters is 'ja’ and the last two characters are ‘es’
SELECT * FROM employee WHERE employee_name like 'ja_es';

14.        Explain the = and != comparison operators with an example for MySQL Select.
= and != are used to fire Select queries for matching the data in the database.

•    = comparison operator – Equals to
select fname, lname from employees
where lname=’jones’;
•    = comparison operator – not Equals to also represented as <>
select fname, lname from employees
where lname != ’jones’;
15.        Discuss about comparison operator in MySQL. How to use Comparison operator in MySQL?
There are many comparison operators supported in Mysql. Comparison operations result in a value 1 or 0 or NULL. Following are the examples:
•    = - Equal to
Select 1=0
->0
•    OR != - Not equal to
Select ‘yes’ != ‘yess’
->1
•    <= and >= - Less than equal to or greater than equal to
Select 2<=2
1
16.        Explain the use of Concat() functions. Provide an example to explain it.(Please provide output of each example)
Concat function is used to combine results from several different fields.
Syntax:
CONCAT(str1, str2, str3, ...):
Example:
SELECT CONCAT(employee_firstname,employee_lastname) FROM employee WHERE employee_salary > 1000;
Output:
John Payne
Mike Turner

17.        Explain the following functions with an example.
left(), length(), locate(), lower(), LTRIM(), Right(), RTRIM(), Soundex(), Substring(), Upper()
left() : Returns the leftmost “n” characters from the string str, or NULL if any argument is NULL.
Example:
Select LEFT (‘samplestring’,’4’);
Output:
samp
length(): Returns the length of the string str measured in bytes.
Example:
Select length (‘sample’);
Output:
6
locate(): Used to return the position of the first occurrence of the substring substr in string str. Returns 0 if not found
Example:
select LOCATE(‘sample’,’thesample’);
Output
3
lower(): Returns the characters in lower case
Example:
select LOWER(‘SAMPLE’);
Output:
sample
LTRIM(): Returns the string str with leading space characters removed
Example:
Select LTRIM(‘ sample’);
Output:
sample
Right(): Returns the rightmost n characters from the string str, or NULL if any argument is NULL
Example:
Select RIGHT(‘sample’,’3’);
output:
mple
RTRIM(): Returns the string str with trailing space characters removed
Example:
Select RTRIM(‘sample ‘);
Output:
sample
Soundex(): soundex strings are strings that sound almost the same. Two strings that sound almost the same should have identical soundex strings
Example:
Select SOUNDEX(‘hello’);
Output:
H400
Substring(): there are many forms of the function Substring().The forms without a len argument return a substring from string str starting at position pos.
Example:
Select SUBSTRING(‘sample’,’2’);
Output:
Ample
Upper(): Returns the string str with all characters changed to uppercase according to the current character set mapping
Example:
Select UPPER(‘Hello’);
Output:
HELLO

18.        State Creating tables syntax with an example.
SQL server tables are used to store data. Each table is divided into rows and columns. Each row has some data against the specified column. Each column has a data type thereby restricting the type of data it can accept.
Syntax:
CREATE TABLE "table_name"
("column 1" "data_type_for_column_1",
"column 2" "data_type_for_column_2",
... )
Example:
CREATE TABLE Customer
(ID Integer (10),
First_name Varchar(20));
19.        Explain the capabilities of command ALTER table.
•    Allows renaming an existing table
•    ALTER TABLE can be used to update or modify values of a column.
•    It can be used to drop columns
•    It can be used to add constraints to a table using CHECK
•    It can be used to remove a CHECK constraint.
•    It can be used to add foreign key constraints to a table.
20.        Explain the difference between CHAR and VARCHAR column types.
Char is a data type with fixed length. On the other hand, VARCHAR is of variable length. The size of the columns becomes the storage size when CHAR is used. On the other hand, due to the varied length of VARCHAR, the size of the data entered becomes the storage size. For e.g if a string SAMPLE is stored using data type as CHAR(10), the column will contain SAMPLE with 4 trailing spaces. While id the data type is VARCHAR(10), the column will just have SAMPLE.
21.        Explain the 3 main categories of data types of MySQL.
•    Numeric – MySql supports all Numeric data types like INTEGER, SMALLINT, DECIMAL, FLOAT, REAL etc. Integer data types are usually represented as INT(4).integer types can have an optional UNSIGNED ATTRIBUTE if only non negative numbers need to be allowed. FLOAT is used to represent approximate values. DECIMAL and NUMERIC are used to store exact values. INT takes 4bytes of storage.
•    Date and Time – The types used to represent date and time in MySql are – DATETIME, DATE, TIMESTAMP, TIME and YEAR. TIMESTAMP has an automatic updating behavior. MySql gives a warning if an illegal date is attempted to be entered. Values for a given date and time are retrieved in a standard format. However, it can change as specified by the user. Zero” date or time values used through MyODBC are converted automatically to NULL
•    String – The String types supported in MySql are – CHAR, VARCHAR, TEXT, ENUM, BINARY, SET. Char and Varchar are used to store characters. Example – char(20) can store 20 characters. Char have a fixed specified length while Varchar is variable. BINARY is used to store binary strings. Strings that have no sorting, character set are binary strings. TEXT is used for strong a large string of data. ENUM is used when only a list of values needs to be allowed. SET can have zero or more values chosen from a list of allowed values specified when the table is created.
22.        How is Sequences handled in MySQL?
Sequence in MySql is handled using primary keys. Since the primary key will always be unique it can be generated in a sequence. The column, whose value is expected to be auto incremented, can be set as AUTO_INCREMENT.
23.        Explain to generate sequences without using Auto_increment.
To generate sequences without using auto_increment, LAST_INSERT_ID() is used
If any insert or update is performed using LAST_UPDATE)ID(expr) the next call to LAST_INSERT_ID() with no argument returns the value of expr
MySQL treats the argument passed (expr) to this function as though it was generated as a AUTO_INCREMENT value.
Example:
UPDATE table_name SET column_name LAST_INSERT_ID(column_name+1);
SELECT LAST_INSERT_ID();

24.        What are the purposes of MySQL indexes?
Indexes help us to find data faster. It can be created on a single column or a combination of columns. A table index helps to arrange the values of one or more columns in a specific order.
Purpose:
•    Allow the server to retrieve requested data, in as few I/O operations
•    Improve performance
•    To find records quickly in the database.
25.        Explain the issues working with Auto_increment in MySQL.
If the maximum value of the table on which auto increment is used is exceeded, auto increment stops incrementing. It does NOT result in loosing existing data but throws an error if further inserts are done.

26.        Explain how to generate sequence in MySql.
Syntax for creating sequence:
CREATE SEQUENCE seqname [ INCREMENT increment ]
[ MINVALUE minvalue ] [ MAXVALUE maxvalue ]
[ START start ] [ CACHE cache ] [ CYCLE ]
Example:
CREATE SEQUENCE employee_id
START 200 INCREMENT 1;
PART-B
1.        Discuss about mysql database.
2.        List out the advantages and disadvantages of Mysql
3.        Explain about setting up account.
4.        Explain record selection technology with example.
5.        Explain string properties and its types.
6.        Discuss date and type database.
7.        Discuss about sorting query results.
8.        How will you generate summary.
9.        Discuss sequence with example.
10.        Discuss mysql and web.

UNIT III : OPEN SOURCE PROGRAMMING LANGUAGES
PART-A


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 PHPcommands 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
             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.
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 canbe 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).
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 (orexpressions) 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.properties:

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
v
    String Concatenation Operator
v
     Auto increment and Auto decrement Operators
v
     Comparison Operators
v
     Bitwise Operators
v
    Logical Operators
v
     Casting Operators
v
    Assignment Operators and some miscellaneous Operators
v
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) {
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
   
vA 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
}
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
   
v 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.
v
18.        What is the Drawback of returning the reference?
    The drawback of returning the reference is that it is slower than returning the
v
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
v
variable.
    Arrays can be used in many ways to store and organize data quickly and
v
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.
v
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);
21.        How can you get the size of the array?
   
v The count( ) and sizeof( ) functions are identical in use and effect. They returnthe 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.
v
Sorting associative arrays
    The asort() function orders the array according to the value of each element in ascending order.
v
    we use ksort() function to sort an associative array according to the key in
v
ascending order.
Sorting arrays in the reverse order
    Rsort() function sorts one-dimensional numerically indexed array by the
v
values in reverse order.
    Arsort() function sorts one-dimensional associative array by the values in
v
reverse order.
    _Krsort() function sorts one-dimensional associative array by the keys in
v
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".
v
   
v A class can be defined as a "black box" from where we create our objects and access its attributes (variables) and methods (functions).
25.        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)
26.        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.
27.        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])
28.        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)
29.        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.
30.        What are the concerns of PHP security?
•    Register Globals
•    SQL Injection
•    Cross Site Scripting
•    User login systems
PART-B

1.         Explain PHP Programming using some examples.
2.        Explain Variables, Constants, Data types in PHP with example.
3.        Explain Operators , Statements, Functions and Array in PHP
4.        Explain String Manipulation and expression in PHP.
5.        Explain File handling and Data storage.
6.        Explain PHP and SQL database
7.        Explain PHP and LDAP
8.        Describe PHP Connectivity in detail.
9.        How Sending and receiving E-mails can de achieved.
10.        Explain in detail Debugging and error handling
11.        How Security and Templates can be implemented using PHP.

UNIT IV : PYTHON
PART-A


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.
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
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
11.        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
12.        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!'
13.        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.
14.        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.
15.        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)]
16.        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'
17.        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)]
>>>
18.        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

19.        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))
20.        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'
21.        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')
22.        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
23.        List the file built in methods
File methods come in four different categories:
input
output
movement within a file("intra-file motion") and
miscellaneous
24.        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 textbased environment like a Unix- or DOS-shell.

25.        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.
26.        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.
27.        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.
28.        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
29.        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
30.        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
31.        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.
32.        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.
33.        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
34.        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
35.        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.

PART-B
1.        Explain about Syntax and Style in python
2.        Explain Python Objects
3.        Explain Numbers, Sequences and Strings
4.        Explain Lists , Tuples and Dictionaries
5.        Explain Conditionals and Loops
6.        Exaplin Files –Input/output in python
7.        Explain types Errors and Exceptions in python
8.        Explain Functions and Modules
9.        Explain Classes and OOP.
10.        Explain Execution Environment.


UNIT V : PERL
PART-A


1.    List any two features in Perl.
•    Speed of development
•    Power
•    Usability
•    Editing tools
2.    What is mean by bare words?
Bare words within a script are essentially a bad idea. First perl tries to identify whether the bare word is a proper value, if it can be resolved to a function within the symbol table, then the function called.
3    What are all the types of context in perl?
•    Scalar context means that a scalar value is expected.
•    Array context means that an array is expected.
•    Hash context means that a hash is expected.
•    Code context means that a block of executable code is expected.
4    Define scalar variable.
Scalar variables are simple variables containing only one element--a string, a number, or a reference. Strings may contain any symbol, letter, or number. Numbers may contain exponents, integers, or decimal values. The bottom line here with scalar variables is that they contain only one single piece of data.
5    Define array variable.
Arrays contain a list of scalar data (single elements). A list can hold an unlimited number of elements. In Perl, arrays are defined with the at (@) symbol
Eg:
#!/usr/bin/perl
print "Content-type: text/html \n\n"; #HTTP HEADER
#DEFINE SOME ARRAYS
@days = ("Monday", "Tuesday", "Wednesday");
@months = ("April", "May", "June");

#PRINT MY ARRAYS TO THE BROWSER
print @days;
print "<br />";
print @months;

6    Define Hash variable.
Hashes are complex lists with both a key and a value part for each element of the list. We define a hash using the percent symbol (%).
Eg:
print "Content-type: text/html \n\n"; #HTTP HEADER

#DEFINE SOME ARRAYS
%coins = ("Quarter", 25, "Dime", 10, "Nickle", 5);
%ages = ("Jerry", 45, "Tom", 22, "Vickie", 38);

#PRINT MY HASHES TO THE BROWSER
print %coins;
print "<br />";
print %ages;
7    List any two naming rules in perl.
•    Variable names can start with a letter, or an underscore, although they normally begin with a letter.
•    Variables can start with a number, but they must be entirely composed of that number.
8    Define Literals and its types.
Literal is s value that is represented as is or hard cored in your source code. When you see the four characters 45.5 in programs it really refers to a value of forty five and half. Perl uses four types of literals
•    Numbers
•    Strings
•    Arrays
9    What is mean by Numerical Literal?
Numeric literals are frequently used. They represent a number that your program will need to work with. Most of the time you will use numbers in base ten - the base that everyone uses. However, Perl will also let you use base 8 (octal) or base 16 (hexadecimal).
10    What is mean by String literal?
String Literals are groups of characters surrounded by quotes so that they can be used as a single datum. They are frequently used in programs to identify filenames, display messages, and prompt for input. In Perl you can use single quotes ('), double quotes("), and back quotes (`).
11    Define typeglobs?
By default, Perl variables are global variables, meaning that I can access them from anywhere in the program as long as I know their names. Perl keeps track of them in the symbol table, which is available to the entire program. Each package has a list of defined identifiers just like I showed in the previous section. Each identifier has a pointer (although not in the C sense) to a slot for each variable type. There are also two bonus slots for the variables NAME and PACKAGE, which I'll use in a moment.
12    What is mean by module?
A Perl module is a discrete component of software for the Perl programming language. Technically, it is a particular set of conventions for using Perl's package mechanism that has become universally adopted.[discuss]
A module defines its source code to be in a package (much like a Java package), the Perl mechanism for defining namespaces, e.g. CGI or Net::FTP or XML::Parser; the file structure mirrors the namespace structure (e.g. the source code for Net::FTP is in Net/FTP.pm). Furthermore, a module is the Perl equivalent of the class when object-oriented programming is employed
13.    What is the usage of use?
The method is used only for the modules (only to include .pm type file) The included objects are verified at the time of compilation. No need to give file extension
14    What is the usage of require?
The method is used for both libraries and modules. The included objects are verified at run time.
15    What is the usage of require?
Defines the variables specified in List as being global with in the enclosing block, file, or eval statement. It is effectively the opposite of my. It declares a variable to be global within the entire scope, rather than creating a new private variable of the same name.
16    How do you open a file in perl?
Following is the syntax to open file.txt in writing mode. Here less tha >signe indicates that file has to be opened in writing mode open(DATA, “file.txt”);
17    How do you close a file in perl?
Once you are done reading and writing you should close any open filehandles.
open FILE1, "file.txt" or die $!;
open FILE2, "picture.jpg" or die $!; ...
close FILE2; close FILE1;
18    How to read a file in perl?
If you want to read a text file line-by-line then you can do it as such:
my @lines = <FILE>;
The <FILE> operator - where FILE is a previously opened filehandle - returns all the unread lines of the text file in list context or a single line in scalar context. Hence, if you had a particularly large file and you wanted to conserve memory you could process it line by line:
while (<FILE>)
{ print $_; }
The $_ variable is automatically set for you to the contents of the current line. If you wish you may name your line variable instead:
while (my $line = <FILE>) { ... will set the $line variable to the contents of the current line. The newline character at the end of the line is not removed automatically. If you wish to remove it you can use the chomp command. After all lines have been read the <FILE> operator will return a false value hence causing the loop to terminate.
There may cases where you need to read a file only a few characters at a time instead of line-by-line. This may be the case for binary data. To do just that you can use the read command.
open FILE, "picture.jpg" or die $!; binmode FILE;
my ($buf, $data, $n);
while (($n = read FILE, $data, 4) != 0)
 { print "$n bytes read\n"; $buf .= $data; }
 close(FILE);
19.    Give the Syntax for fcntl.
Fcntl FILEHANDLE, FUNCTION,SCALER
20    What is the use of LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB ?
LOCK_SH  Set shared lock
LOCK_EX  Set exclusive lock
LOCK_UN  Unlock specified lock
LOCK_NB  Set lock without blocking
21    What is the usage of abs function?
Definition and Usage
Returns the absolute value of its argument. If pure interger value is passed then it will return it as it is but if a string is passed then it will return zero. If VALUE is omitted then it uses $_
Return Value
Returns the absolute value of its argument.
Example
Following is the piece of code#!/usr/bin/perl
$par1 = 10.25;
$par2 = 20;
$par3 = "ABC";
$abs1 = abs($par1);
$abs2 = abs($par2);
$abs3 = abs($par3);
print "Abs value of par1 is $abs1\n" ;
print "Abs value of par2 is $abs2\n" ;
print "Abs value of par3 is $abs3\n" ;

PART-B
1  Explain Perl Parsing rules.
3    Explain  Literals in perl.
4    Discuss a)array b) Hash c) List
5    Discuss a)Typeglobs b)Tokens
6    Explain statements and control structures in perl.
7    Explain subroutines and functions.
8    Explain Packages and Modules.
9    Discuss a) scope b) auto loading.
10    Explain File handling and File Management in perl.
11.    Discuss about working with numbers in perl.
12.    Discuss about working with strings in perl.
13    Explain a) Pattern Modifiers b) Match operator c) Substitution operator
14.    Explain a) Translation b) Precompiling Expressions



No comments:

Post a Comment