0% found this document useful (0 votes)
12 views21 pages

PLP Question Bank For Reference Purpose

The document is a question bank for programming languages, covering topics such as factors influencing programming language evolution, context-free grammar components, stages of language translation, syntactic elements, pointers, sequence control, scalar type variables, and the differences between procedures and functions. It emphasizes the importance of readability, writability, reliability, and cost in programming languages, along with the structure of compilers and the significance of local referencing environments in subprograms. The content serves as a reference for studying programming language concepts and should be supplemented with additional resources.

Uploaded by

Narendra Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views21 pages

PLP Question Bank For Reference Purpose

The document is a question bank for programming languages, covering topics such as factors influencing programming language evolution, context-free grammar components, stages of language translation, syntactic elements, pointers, sequence control, scalar type variables, and the differences between procedures and functions. It emphasizes the importance of readability, writability, reliability, and cost in programming languages, along with the structure of compilers and the significance of local referencing environments in subprograms. The content serves as a reference for studying programming language concepts and should be supplemented with additional resources.

Uploaded by

Narendra Patil
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

PLP Question Bank For Reference purpose

NOTE: This Question Bank is only for reference purpose please do not depend totally on these
questions.

Study from the given syllabus and cover all the points.

1. What are the different factors that influences the evolution of programming languages?

Ans : Different language evaluation criteria are

Readability

Software development was largely thought of in term of writing code “LOC”.

Language constructs were designed more from the point of view of the computer than the users.
Because ease of maintenance is determined in large part by the readability of programs, readability
became an important measure of the quality of programs and programming languages. The result is a
crossover from focus on machine orientation to focus on human orientation. The most important
criterion “ease of use”

Writability

It is a measure of how easily a language can be used to create programs for a chosen problem domain.

Most of the language characteristics that affect readability also affect writability.

Simplicity and orthogonality

A smaller number of primitive constructs and a consistent set of rules for combining them is much better
than simply having a large number of primitives.

Support for abstraction

Abstraction means the ability to define and then use complicated structures or operations in ways that
allow many of the details to be ignored.

A process abstraction is the use of a subprogram to implement a sort algorithm that is required several
times in a program instead of replicating it in all places where it is needed.

Expressivity

It means that a language has relatively convenient, rather than cumbersome, ways of specifying
computations.

Ex: ++count ⇔ count = count + 1 // more convenient and shorter


Reliability

A program is said to be reliable if it performs to its specifications under all conditions.

Type checking: is simply testing for type errors in a given program, either by the compiler or during
program execution.

The earlier errors are detected, the less expensive it is to make the required repairs. Java requires type
checking of nearly all variables and expressions at compile time.

Exception handling: the ability to intercept run-time errors, take corrective measures, and then continue
is a great aid to reliability.

Aliasing: it is having two or more distinct referencing methods, or names, for the same memory cell.

It is now widely accepted that aliasing is a dangerous feature in a language. Readability and writability:
Both readability and writability influence reliability.

Cost

Categories

Training programmers to use language

Writing programs “Writability”

Compiling programs

Executing programs

Language implementation system “Free compilers is the key, success of Java”

Reliability, does the software fail?

Maintaining programs: Maintenance costs can be as high as two to four times as much as development
costs.

Portability “standardization of the language”

Generality (the applicability to a wide range of applications)

Q 2. What are the different components of the context free grammar used for programming language
construction?

Ans: A CFG consists of the following components:

• a set of terminal symbols, which are the characters of the alphabet that appear in the strings
generated by the grammar.

• a set of nonterminal symbols, which are placeholders for patterns of terminal symbols that can be
generated by the nonterminal symbols.
• a set of productions, which are rules for replacing (or rewriting) nonterminal symbols (on the left side
of the production) in a string with other nonterminal or terminal symbols (on the right side of the
production).

• a start symbol, which is a special nonterminal symbol that appears in the initial string generated by the
grammar.

To generate a string of terminal symbols from a CFG, we:

• Begin with a string consisting of the start symbol;

• Apply one of the productions with the start symbol on the left hand size, replacing the start symbol
with the right hand side of the production;

• Repeat the process of selecting nonterminal symbols in the string, and replacing them with the right
hand side of some corresponding production, until all nonterminals have been replaced by terminal
symbols.

Q. 3: Explain in detail different stages in language translation.

Ans: language translation work done by compiler

Structure of Compiler: A compiler takes input as source program and produces as output an equivalence
sequence of machine instructions.

The compilation process is divided into a series of sub process called phases. A phase is a logically
cohesive operation that takes as input one representation of source program and produce as output i.e;
target program in other representation.

Phases of Compilation:

1. First Phase: lexical analyzer or scanner separate character of source language into a group of logically
belongs to each other. This group is called as tokens. The usual tokens are keywords such as do or if,
identifiers such as a or b, operator symbol as = + < > and punctuation symbol as () and comma. The
output is a stream of tokens pass to the rest of phases.

2. Second Phase: the syntax analyzer or parser group tokens together into syntactic structure for
example 3 tokens as A+B group together into syntactic structure as expression. Expression might further
be combined into statement. We form a tree who's leaf are tokens, an interior node represent string of
token that logically belong together. for example : the statement - if(5 equ max) goto 100 has 8 tokens.

3. Third Phase: intermediate code generator use the structure produced by syntax analyzer to create a
stream of simple instructions. Different style we are using like MACROS.

4. Fourth Phase: code optimization is an optional phase design to improve the intermediate code so that
object program run faster and take less space. Its output is also intermediate code but it saves time.
5. Fifth Phase: the final phase at code generation produce the object code by deciding on memory
location for data, selecting code and selecting register in which each computation done.

The table management or book keeping keeps track of the name and record and all the essential
information about each of the data type. The data structure which is used to record the information
called the symbol table.

Q. 4: Explain various syntactic elements of language with the help of examples.

Ans:

The different syntactic elements are:

a) Character set : The choice of character set is one of the first to be made in designing language syntax.
The character set is nothing but group of characters which are allowed programming language including
special characters such as 'A', '\n'. n'. Each language may have its own character set or may language can
share same set.

b) Identifiers : Identifier is a string of letters & digits beginning with a letter. These are names that are
given to various program elements, such as variables, functions.

c) Operator Symbols Most languages use the special characters + and — to represent the two basic
arithmetic operations. Primitive operations may be represented entirely by special characters like APL.

d) Keywords & Reserved Words :

1) Keyword : "A keyword is an identifier used as a fixed part of the syntax of a statement. Example 'if '
beginning a 'C' conditional statement. 'for' beginning a 'C' iterative statement.

2) Reserved word : like NULL

e) Noise Words: Noise words are optional words that are inserted in statement to improve readability.
For example, in COBOL, the 'GO TO' statement transfer control within the program. It is written as, GO
TO label.

Where GO is required & TO is optional; it carries no information & is only used to improve readability.

f) Comments: Inclusion of comment in a program is an important part of its documentation. A language


may allow comments in several ways:
g) Blank Spaces: Rules on the use of blanks vary widely between languages. In 'C', blanks are used with
characters & string data and separator between elements of statements

h) Delimiters & Brackets:

i) Free and Fixed-Field Formats:

J) Expressions:

k) Statement:

Q. : Define pointer. Explain various design issues of pointer and pointers in c/c++.

Ans :

Pointer is a variable that represents the location of a data item, such as variable or an array element.
Within the computer’s memory, every stored data item occupies one or more contiguous memory cells.
The number of memory cells required to store a data item depends on the type of the data item. For
example, a single character will typically be stored in one byte of memory; an integer usually requires
two contiguous bytes, a floating-point number usually requires four contiguous bytes, and a double
precision usually requires eight contiguous bytes.

Suppose v is a variable that represents some particular data item. The compiler will automatically assign
memory cells to this data item. The data item can then be accessed if we know the address of the first
memory cell. The address of v’s memory location can be determined by the expression &v, where & is
the unary operator, called the address operator, that evaluates the address of its operand.

Now let us assign the address of v to another variable pv. Thus pv = &v;

This new variable is called pointer to v. since it “points to” the location where v is stored in address, not
its value. Thus pv is referred to as a pointer variable. The relationship between pv and v is illustrated in
the following figure.

Address of V-----------> Value of V

For example,

a C program contains the following declarations.

int i,*ptri;

float f,*ptrf;

The first line declares i to be an integer type variable and ptri to be a pointer variable whose object is an
integer quantity. The second line declares f to be a floating-point type variable and ptrf to be a pointer
variable whose object is a floating point quantity.
Within a variable declaration, a pointer variable can be initialized by assigning in the address of another
variable, remember that the variable whose address is assigned to the pointer variable must have been
declared earlier in the program, for example,

int i;

int *ptri=&i;

The first line declares i to be integer type variable and the second line declares ptri to be a pointer
variable whose object is an integer point quantity. In addition, the address of i is initially assigned to ptri.

Q. : Explain the problem caused by uniform evaluation rule while evaluating an expression and the
solution to the problem.

Ans The solution of the problem caused by uniform evaluation rule can be solved by associativity, the
associativity (or fixity) of an operator is a property that determines how operators of the same
precedence are grouped in the absence of parentheses. If an operand is both preceded and followed by
operators (for example, "^ 4 ^"), and those operators have equal precedence, then the operand may be
used as input to two different operations (i.e. the two operations indicated by the two operators). The
choice of which operations to apply the operand to, is determined by the "associativity" of the
operators. Operators may be associative (meaning the operations can be grouped arbitrarily), left-
associative (meaning the operations are grouped from the left), right-associative (meaning the
operations are grouped from the right) or non-associative (meaning operations cannot be chained, often
because the output type is incompatible with the input types). The associativity and precedence of an
operator is a part of the definition of the programming language; different programming languages may
have different associativity and precedence for the same type of operator.

Consider the expression a ~ b ~ c. If the operator ~ has left associativity, this expression would be
interpreted as (a ~ b) ~ c. If the operator has right associativity, the expression would be interpreted as a
~ (b ~ c). If the operator is non-associative, the expression might be a syntax error, or it might have some
special meaning. Some mathematical operators have inherent associativity. For example, subtraction
and division, as used in conventional math notation, are inherently left-associative. Addition and
multiplication, by contrast, have no inherent associativity, though most programming languages define
associativity for these operations as well.

Many programming language manuals provide a table of operator precedence and associativity; see, for
example, the table for C and C++.

The concept of notational associativity described here is related to, but different from the mathematical
associativity. An operation that is mathematically associative, by definition requires no notational
associativity. (For example, addition has the associative property, therefore it does not have to be either
left associative or right associative.) An operation that is not mathematically associative, however, must
be notationally left-, right-, or non-associative. (For example, subtraction does not have the associative
property, therefore it must have notational associativity.)

Q.: What is sequence control? Explain various categories of sequence control.

Ans

The control of execution of the operations, both primitive and user defined, is termed as sequence
control.

Sequence control structures are categorized into following four groups:

1. Expressions : These form the basic building blocks for statements and express how at are manipulated
and changed by a program. Properties such as precedence rules and parentheses determine how
expressions become evaluated.

2. Statement; : Statements such as conditional or iterative statements, determine how control flows
from one segment of a program to another.

3. Declarative programming: It is an execution model that does not depend on statements, but
nevertheless causes execution to proceed through a program.

4. Subprograms :Subprograms such as subprogram calls and coroutines, form a way to transfer control
from one segment of a program to another.

i) Implicit and Explicit Sequence Control:

Sequence control structures may be either implicit or explicit.

i) Implicit sequence-control structures:

These are defined by language to be in effect ’un1es'smodified by the programmer through some
explicit structure. For example, most languages define the physical sequence of statements in a program
as controlling the sequence in which statements are executed, unless modified by an explicit sequence-
control statement.

ii) Explicit sequence-control structure

These are the sequence-control structures that the programmer may optionally use to modify the
implicit sequence of operations defined by the language.

Q. : Explain the different categories of scalar type variables with their advantage and disadvantages.
Variables are identifiers used in a program to represent the different kinds of data. The variables holding
data of scalar data types are known as scalar variables. They are the most common ways of storing data.

The scalar variables are used to hold fundamental types of data in a program. Literals can also be used
to refer to data in a program. Based on the kind of data stored or represented, the variables or the
literals belong to the respective data type.

The scalar type variables are introduced in a program by means of declarations. A declaration is a

statement in a program that defines variables of a specific data type. A variable declaration statement
fixes the name and data type of the variables it defines. The type then restricts the set of possible values
which can be stored in the variables and also defines the memory requirements for storing actual
values. In Java such amount of memory is fixed for each type and known at compile time. Variables
declaration is essential for their use. If we do not declare variables they are not known to the compiler,
it is not able to check if they are used according to the restrictions of the type, they belong to. Hence, all
the variables must be declared prior to using them in a program. The format of declaring the scalar
variables is given below:

type varl, var2, varN ;

where,

type represents a valid data type

varl, var2, varN represent variable names that are called declarators.

Q. : What is the difference between procedure and function? Explain with suitable example

Ans:

1. Procedure may or may not return value where as function should return one value.

2. Procedure can performs one or more tasks where as function performs a specific task.

3. we can call functions in select statement where as procedure we cant.

4. We can call Stored Procedure within function but we can not call function within stored procedure.
5.A FUNCTION must be part of an executable statement, as it cannot be executed independently where
as procedure represents an independent executable statement.

5. Function can be called form SQL statement where as procedure can not be called from the SQL
statement.
6. Function are normally used for computation where as procedure are normally used for executing
business logic.

7. Stored procedure supports deferred name resolution where as function wont support.

8. Stored procedure returns always integer value by default zero. whrer as function returns type could
be scalar or table or table value. 10.Stored procedure is precompiled execution plan where as function
are not.

Q. : What do you mean by referencing environment of sub program? Discuss its several components ?

ANS: LOCAL REFERENCING ENVIRONMENTS

• Subprograms are generally allowed to define their own variables, thereby defining local referencing
environments. Variables that are defined inside subprograms are called local variables because access to
them is usually restricted to the subprogram in which they are defined.

• If local variables are stack dynamic, they are bound to storage when the subprogram begins execution
and unbound from storage when that execution terminates. An advantage of this is flexibility.

• It is important that recursive subprograms have stack dynamic local variables.

• Another advantage is that some of the storage for local variables of all subprograms can be shared

• Main disadvantages of stack dynamic local variables are:

o Cost of time required to allocate, initialize and de-allocate for each activation

o Accesses of stack dynamic local variables must be indirect, where accesses to static can be direct

o Stack dynamic local variables, the subprograms cannot retain data values of local variables between
calls.

• The primary advantage of static local variables is that they are very efficient because of no indirection

Q. : Explain the following implementation models for parameter passing with an example.

i) Pass-By-value

ii) Pass-By-value-Result

iii) Pass-By-Reference

iv) Pass-By-Name

Ans: Parameter Passing methods

Pass-by-Value

When a parameter is passedby value, the value of the actual parameter is used to initialize the
corresponding formal parameter, which then acts as a local variable in the subprogram, thus
implementing in-mode semantics.
Pass-by-Result

Pass-by-result is an implementation model for out-mode parameters. When a parameter is passed by


result, no value is transmitted to the subprogram. The corresponding formal parameter acts as a local
variable, but just before control is transferred back to the caller, its value is transmitted back to the
caller’s actual parameter, which obviously must be a variable.

Pass-by-Value-Result

Pass-by-value-result is an implementation model for inout-mode parameters in which actual values are
copied. It is in effect a combination of pass-by-valueand pass-by-result. The value of the actual
parameter is used to initialize the corresponding formal parameter, which then acts as a local variable.
In fact, pass-by-value-result formal parameters must have local storage associated with the called
subprogram. At subprogram termination, the value of the formal parameter is transmitted back to the
actual parameter. Pass-by-value-result is sometimes called pass-by-copy, because the actual parameter
is copied to the formal parameter at subprogram entry and then copied back at subprogram
termination.

Pass-by-Reference

Pass-by-reference is a second implementation model for inout-mode parameters.Rather than copying


data values back and forth, however, as in pass-byvalue-result, the pass-by-reference method transmits
an access path, usually just an address, to the called subprogram. This provides the access path to the
cell storing the actual parameter. Thus, the called subprogram is allowed to access the actual parameter
in the calling program unit. In effect, the actual parameter is shared with the called subprogram.

Pass-by-Name :

In this method, the arguments to a function arc not evaluated before the function is called. Their
identifications arc substituted directly into the function body and then left to be evaluated whenever the
function encounters them. If an argument is not actually used in the function body that argument is
never evaluated and if it is used several times, it is re-evaluated each time it appears. This is one of the
most complex argument passing methods to implement. Effectively, each argument is as if represented
by its own evaluation function reference. In the language FORTH, the variables are passed in sonic what
similar fashion.

Q. : Explain different elements which require storage during program execution.

The major program and data elements requiring storage during program execution. Code segments for
translated user programs A major block of storage in any system must he allocated to store the code
segments representing the translated form of user programs, regardless of whether programs are
hardware- or software-interpreted. In the former case, programs are blocks of executable machine
code; in the latter case, blocks are in some intermediate form. System run-time programs Another
substantial block of storage during execution must be allocated to system programs that support the
execution of the user programs. These may range from simple library routines; such as sine, cosine, or
print-string functions, to software interpreters or translators present during execution. Also included
here are the routines that control run-time storage management. User-defined data structures and
constants. Space for user data must be allocated for all data structures declared in or created by user
programs including constants. Subprogram return points Subprograms may be invoked from different
points in a program.

Therefore, internally generated sequence-control information, such as subprogram return points,


coroutine resume points, or event notices for scheduled subprograms, must be allocated storage.
Referencing environments Storage of referencing environments (identifier associations) during
execution may require substantial space, as. for example, the LISP A-list. Temporaries in expression
evaluation. Expression evaluation requires the use of system-defined temporary storage for the
intermediate results of evaluation. For example, in evaluation of the expression (x + y)x(u + v), the result
of the first addition may have to be stored in a temporary while the second addition is performed. When
expressions involve recursive function calls, a potentially unlimited number of temporaries may be
required to store partial results at each level of recursion. Temporaries in parameter transmission.
When a subprogram is called, a list of actual parame- ters must be evaluated and the resulting values
stored in temporary storage until evaluation of the entire list is complete. Where evaluation of one
parameter may require evaluation of recursive func- tion calls. a potentially unlimited amount of storage
may be required, as in expression evaluation. Input-output buffer& Ordinarily input and output
operations work through buffers, which serve as temporary storage areas where data are stored
between the time of the actual physical transfer of the data to or from external storage and the
program-initiated input and output operations. Miscellaneous system data. In almost every language
implementation, storage is required for various system data: tables, status information for input-output,
and various miscellaneous pieces of state information (e.g., reference counts or garbage-collection bits).
Besides the data and program elements requiring storage. various operations may require storage to be
allocated or freed. The following are the major operations: Subprogram call and rerun: operations The
allocation of storage for a subprogram activation record, the local referencing environment, and other
data on call of a subprogram is often the major operation requiring storage allocation. The execution of
a subprogram return operation usually requires freeing of the storage allocated during the call.

Q. : Explain the concept of abstraction and encapsulation with suitable example.

ANS

Abstraction "Abstraction refers to the act of representing essential features without including
background details or explanations." The main idea behind data abstraction is to give a clear separation
between properties of data type and the associated impiementation details. This separation is achieved
in order that the properties of the abstract data type are visible to the user interface and the
implementation details are hidden. Thus, abstraction forms the basic platform for the creation of user-
defined data types called objects. Data abstraction is the process of refining data to its essential form. In
object-oriented programming language C++, it is possible to create and provide an interface that
accesses only certain elements of data types. The programmer can decide which user to give org rant
access to and hide the other details. This concept is called data a hiding which is similar in concept to
data abstraction. Example : When designing a class student in C++, we need the data elements such as
rotno, student_ name, marks, grade, etc. If we now design a class representing a cricket player we need
details like player_name, no_of centuries, striking ,rate, no_ofs matches played, etc. It will not make
sense to add the player's marks, grades which are applicable to a student class to this player class.

Encapsulation Encapsulation is the process of combining or packaging data with functions and thereby
The concept of abstraction brings forth another related term known as encapsulation. "The wrapping up
of data and functions that act upon that data in a single unit is termed as encapsulation". It binds
together both the data and code and thus keeps both safe from the outside world. The data and the
code to manipulate the data are combined in such a way that a black box is created which is self
contained and modular. This box is termed as a class in object oriented terminology. Within a class the
code or the data can be private or public. If it is private then these cannot be accessed by the outside
world whereas public means that the code and the data is accessible to everyone. Typically the data is
private and the methods are an interface to the private elements of the object. Thus, encapsulation
allows users to create a new data type. This new data type is termed abstract data type. Though the new
data type is similar to that of built-in data type, it is termed abstract data type because it enables users
to abstract a concept from the problem space into the solution space. Apart from the above, all the
features that hold for built-in types also hold solution space. Apart from the above, all the features that
hold for built-in types also hold for abstract data types. Data encapsulation led to the important concept
of data hiding. Data hiding is the implementation details of a led to the important concept of data
hiding. Data hiding is the implementation details of a Class that are hidden from the user. Class that are
hidden from the user.

public class Employee {

private BigDecimal salary = new BigDecimal(50000.00);

public BigDecimal getSalary() {

return salary;

public static void main() {

Employee e = new Employee();

BigDecimal sal = e.getSalary();

Q. : Explain Briefly:

i) Garbage collection
ii) Semaphores

Ans : i) Garbage collection (also known as GC) is a form of automatic memory management. The garbage
collector or collector attempts to reclaim garbage, or memory used by objects that will never again be
accessed or mutated by the application. Garbage collection is often portrayed as the opposite of manual
memory management, which requires the programmer to specify which objects to deallocate and return
to the memory system. However, many systems use a combination of the two approaches, and there
are other techniques being studied (such as region inference) to solve the same fundamental problem.
Note that there is an ambiguity of terms, as theory often uses the terms manual garbage-collection and
automatic garbage-collection rather than manual memory management and garbage-collection, and
does not restrict garbage-collection to memory management, rather considering that any logical or
physical resource may be garbage-collected.

Description

The basic principle of how a garbage collector works is:

1. Determine what data objects in a program will not be accessed in the future

2. Reclaim the storage used by those objects

By making manual memory deallocation unnecessary (and typically impossible), garbage collection frees
the programmer from having to worry about releasing objects that are no longer needed, which can
otherwise consume a significant amount of design effort. It also aids programmers in their efforts to
make programs more stable, because it prevents several classes of runtime errors. For example, it
prevents dangling pointer errors, where a reference to a deallocated object is used.

ii) A semaphore is a protected variable whose value can be accessed and altered only by the operations
P and V and initialization operation called 'Semaphoiinitislize'.

Binary Semaphores can assume only the value 0 or the value 1 counting semaphores also called general
semaphores can assume only nonnegative values.

The P (or wait or sleep or down) operation on semaphores S, written as P(S) or wait (S), operates as
follows:

P(S): IF S > 0
THEN S := S - 1

ELSE (wait on S)

The V (or signal or wakeup or up) operation on semaphore S, written as V(S) or signal (S), operates as
follows:

V(S): IF (one or more process are waiting on S)

THEN (let one of these processes proceed)

ELSE S := S +1

Operations P and V are done as single, indivisible, atomic action. It is guaranteed that once a semaphore
operations has stared, no other process can access the semaphore until operation has completed.
Mutual exclusion on the semaphore, S, is enforced within P(S) and V(S).

If several processes attempt a P(S) simultaneously, only process will be allowed to proceed. The other
processes will be kept waiting, but the implementation of P and V guarantees that processes will not
suffer indefinite postponement.

Q. : What is concurrency? Discuss various categories of concurrency?

ANS:

Concurrency refers to techniques that make program more usable. Concurrency can be implemented
and is used a lot on single processing units, nonetheless it may benefit from multiple processing units
with respect to speed. If an operating system is called a multi-tasking operating system, this is a
synonym for supporting concurrency. If you can load multiple documents simultaneously in the tabs of
your browser and you can still open menus and perform more actions, this is concurrency. On a single-
processor machine, the operating system’s support for

concurrency allows multiple applications to share resources in such a way that applications appear to
run at the same time. Since a typical application does not consume all resources at a given time, a
careful coordination can make each application run as if it owns the entire machine.
An analogy is juggling. While there are only two hands, each ball thinks that it is caught and tossed with
a pair of dedicated hands.

There are a number of benefits for an operating system to provide concurrency:

1. Of course, the most obvious benefit is to be able to run multiple applications at the same time.

2. Since resources that are unused by one application can be used for other applications, concurrency
allows better resource utilization.

3. Without concurrency, each application has to be run to completion before the next one can be run.
Therefore, concurrency allows a better average response time of individual applications.

4. Concurrency does not merely timeshare the computer; concurrency can actually achieve better
performance. For example, if one application uses only the processor, while another application uses
only the disk drive, the time to run both applications concurrently to completion will be shorter than the
time to run each application consecutively.

Concurrency also introduces certain drawbacks:

1. Multiple applications need to be protected from one another.

2. Multiple applications may need to coordinate through additional mechanisms.

3. Switching among applications requires additional performance overheads and complexities in


operating systems (e.g., deciding which application to run next.)

4. In extreme cases of running too many applications concurrently will lead to severely degraded
performance.

Q. : Explain the use of predicate calculus in logic programming.

Ans:

• Predicate calculus gives the underpinnings to the languages of logic programming, such as Prolog.
• Predicate calculus is increasingly used for specifying the requirements of computer applications.

• In the area of proving program correctness, predicate calculus allows one to precisely state under
which conditions a program gives the correct output.

Q. : How functions are declared in functional programming language.

Function Declaration

A function declaration introduces a function or method into your program. A function declared in the
context of class, structure, enumeration, or protocol is referred to as a method. Function declarations
are declared using the keyword func and have the following form:

func function name(parameters) -> return type {

statements

If the function has a return type of Void, the return type can be omitted as follows:

func function name(parameters) {

statements

The type of each parameter must be included—it can’t be inferred. Although the parameters to a
function are constants by default, you can write let in front of a parameter’s name to emphasize this
behavior. Write var in front of a parameter’s name to make it a variable, scoping any changes made to
the variable just to the function body, or write inout to make those changes also apply to the argument
that was passed in the caller’s scope. For a discussion of in-out parameters, see In-Out Parameters.

Functions can return multiple values using a tuple type as the return type of the function.

A function definition can appear inside another function declaration. This kind of function is known as a
nested function. For a discussion of nested functions, see Nested Functions.

Q. : How functions are declared in functional programming language.

Function Declaration

A function declaration introduces a function or method into your program. A function declared in the
context of class, structure, enumeration, or protocol is referred to as a method. Function declarations
are declared using the keyword func and have the following form:

func function name(parameters) -> return type {

statements

If the function has a return type of Void, the return type can be omitted as follows:
func function name(parameters) {

statements

The type of each parameter must be included—it can’t be inferred. Although the parameters to a
function are constants by default, you can write let in front of a parameter’s name to emphasize this
behavior. Write var in front of a parameter’s name to make it a variable, scoping any changes made to
the variable just to the function body, or write inout to make those changes also apply to the argument
that was passed in the caller’s scope. For a discussion of in-out parameters, see In-Out Parameters.

Functions can return multiple values using a tuple type as the return type of the function.

A function definition can appear inside another function declaration. This kind of function is known as a
nested function. For a discussion of nested functions, see Nested Functions.

Q. : what is exception and exception handling explains with example.

ANS: Exception handling

is the process of responding to the occurrence, during computation, of exceptions – anomalous or


exceptional events requiring special processing – often changing the normal flow of program execution.
It is provided by specialized programming language constructs or computer hardware mechanisms.

In general, an exception is handled (resolved) by saving the current state of execution in a predefined
place and switching the execution to a specific subroutine known as an exception handler. If exceptions
are continuable, the handler may later resume the execution at the original location using the saved
information.

For example, a floating point divide by zero exception will typically, by default, allow the program to be
resumed, while an out of memory condition might not be resolvable transparently. Alternative
approaches to exception handling in software are error checking, which maintains normal program flow
with later explicit checks for contingencies reported using special return values or some auxiliary global
variable such as C's errno or floating point status flags; or input validation to preemptively filter
exceptional cases.

Q What is Semaphores? A counting semaphore S is initialized to 7. Then, 20 P operations and


15 V operations are performed on S. What is the final value of S?
Ans :-

semaphore (F) = 5 Calculation: 5 = 7 + x V + 20 P 5 = 7 + x (+1) + 20 (-1) x = 5 - 7 + 20 ∴ x = 18


Initial counting semaphore (I) = 7 Signal operation = x V Wait operation = 20 P Final counting

Justify your answer

Q Represent communication between client and server along with diagram. Differentiate between
Client-Side Scripting and Server Side Scripting language.
Q Write a program using java script to find out string staring with @ and ending with #. count the no of
occurrences of the same.

Q What are the different factors that influences the evolution of programming languages?

Q Explain the following implementation models for parameter passing with an example.

Pass-By-value

Pass-By-value-Result

Pass-By-Reference

Pass-By-Name

Q Select appropriate programming paradigm to write a program to calculate the area of shape. Circle
has data member radius and Rectangle has data member length and breadth. Both Circle and Rectangle
have function named area( ) to calculate area

Q Answer the following

Q What do you mean by referencing environment of sub program? Discuss its several components?

Q What is the difference between procedural programming paradigm and functional programming
paradigm? Which of the both follows lazy evaluation.

Q What is Multithreading? Give an example of multithreading in Python

Q Explain in detail different stages in language translation.

Q Write a Program to multiply each numbers from given list by 10 using lambda function.

Q Answer the following

Q Explain different elements which require storage during program execution.

Q State the different categories of scalar type variables with their advantage and disadvantages.

Q Write the output of the following program along with the explanation:

(a) void main ()

int x = 128;

printf ("%d", 1 + x++);

(b)
(c) r = lambda g: g * 2

s = lambda g: g * 3

x=2

y= 3

x = r(x)

y = s(y)

print(x)

print(y)

(d)

(e) int main()

char arr[7]="Network";

printf("%s", arr);

return 0;

Q What are the different components of the context free grammar used for programming language
construction?

Q For a Given grammar, construct an operator precedence relation matrix, assuming *, + are binary
operators and id as terminal Symbol and S, A, B as non-terminal symbol.

S →S+A/A

A→ A*B/B

C→A-B

B → id

Apply operator precedence parsing algorithm for the given input string

id + id * id
Q Consider the following grammar and eliminate left recursion-

S → (L) / a

L → L,S / S

Q Consider the following grammar and eliminate left recursion-

S→A

A → Ad / Ae / aB / ac

B → bBc / f

Q Explain the problem caused by uniform evaluation rule while evaluating an expression and the
solution to the problem.

Q Create the knowledge base for the following and answer the give queries.

mack is a cat

mack has black spots

max is a dog

max has white spots

jeny owns a Pet if it is a cat and it has black spots

jem owns a pet if it is a dog and it has white spots

If someone owns something, he loves it.

Who owns dog?

Who loves max?

Who loves what?

Does jem own something?

Does jeny own something?

Who is dog?

***********************************************************************************

NOTE: This Question Bank is only for reference purpose please do not depend totally on these
questions.

Study from the given syllabus and cover all the points.

************************************All The Best***********************************

You might also like