Saturday 7 September 2013

BEL Model Question Papers With Answers


BEL Model Question Papers With Answers


BHL Computer Science Model Question Paper With Answers  :

Which is the parameter that is added to every non-static member function when it is

called?
Answer:  'this' pointer 

What is a binary semaphore? What is its use?
Answer: A binary semaphore is one, which takes only 0 and 1 as values. They are used to implement mutual exclusion and synchronize concurrent processes.

What is thrashing?

Answer: It is a phenomenon in virtual memory schemes when the processor spends most of its time swapping pages, rather than executing instructions. This is due to an inordinate number of page faults.

What are turnaround time and response time?

Answer: Turnaround time is the interval between the submission of a job and its completion. Response time is the interval between submission of a request, and the first response to that request.

What is data structure?

Answer: A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data.

List out the areas in which data structures are applied extensively?

Answer: The name of areas are:
Compiler Design,
Operating System,
Database Management System,
Statistical analysis package,
Numerical Analysis,
Graphics,
Artificial Intelligence,
Simulation
What are the major data structures used in the following areas : RDBMS, Network data model & Hierarchical data model.
Answer: The major data structures used are as follows:
RDBMS - Array (i.e. Array of structures)
Network data model - Graph
Hierarchical data model - Trees 

What is the data structures used to perform recursion?

Answer: 
Stack. Because of its LIFO (Last In First Out) property it remembers its 'caller' so knows whom to
return when the function has to return. Recursion makes use of system stack for storing the return
addresses of the function calls.
Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent
iterative procedures are written, explicit stack is to be used.

Predict the output or error(s) for the following:

void main()
{
int const * p=5;
printf("%d",++(*p));
}
Answer:
Compiler error: Cannot modify a constant value.

Explanation:p is a pointer to a "constant integer". But we tried to change the value of the "constant

integer".

main()

{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
Answer:
mmmm
aaaa
nnnn
Explanation:s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same idea. Generally array name is the base address for that array. Here s is the base address. i is the index number/displacement from the base address. So, indirecting it with * is same as s[i]. i[s] may be surprising. But in the case of C it is
same as s[i].

main()

{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
}
Answer:
I hate U
Explanation:For floating point numbers (float, double, long double) the values cannot be predicted
exactly. Depending on the number of bytes, the precession with of the value represented varies. Float
takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double.
Rule of Thumb:
Never compare or at-least be cautious when using floating point numbers with relational operators (== , >,
<, <=, >=,!= ).

List out few of the Application of tree data-structure?
Answer: The list is as follows:
The manipulation of Arithmetic expression,
Symbol Table construction,Symbol Table construction,
Syntax analysis.

List out few of the applications that make use of Multi linked Structures?

Answer: The applications are listed below:
Sparse matrix,
Index generation.

In tree construction which is the suitable efficient data structure?
Answer: Linked list is the efficient data structure.

What is the type of the algorithm used in solving the 8 Queens problem?
Answer: Backtracking

In RDBMS, what is the efficient data structure used in the internal storage representation?

Answer: B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes searching
easier. This corresponds to the records that shall be stored in leaf nodes.

Whether Linked List is linear or Non-linear data structure?

Answer: According to Access strategies Linked list is a linear one.

According to Storage Linked List is a Non-linear one.

Predict the output or error(s) for the following:
main()
{
int c=- -2;
printf("c=%d",c);
}
Answer:
c=2;
Explanation:Here unary minus (or negation) operator is used twice. Same maths rules applies, ie. minus *
minus= plus.


#define int char main()

{
int i=65;
printf("sizeof(i)=%d",sizeof(i));
}
Answer:
sizeof(i)=1
Explanation: Since the #define replaces the string int by the macro char What is dangling pointer in c?
If any pointer is pointing the memory address of any variable but after some variable has deleted from that memory location while pointer is still pointing such memory location. Such pointer is known as dangling pointer and this problem is known as dangling pointer problem.

In C++, what is the difference between method overloading and method overriding?

Overloading a method (or function) in C++ is the ability for functions of the same name to be defined as
long as these methods have different signatures (different set of parameters). Method overriding is the
ability of the inherited class rewriting the virtual method of the base class.

What methods can be overridden in Java?

Answer: In C++ terminology, all public methods in Java are virtual. Therefore, all Java methods can be overwritten in subclasses except those that are declared final, static, and private.

What are the defining traits of an object-oriented language?

Answer: The defining traits of an object-oriented langauge are:
* encapsulation
* inheritance* inheritance
* polymorphism Write a program that ask for user input from 5 to 9 then calculate the average
int main()
{
int MAX=4;
int total =0;
int average=0;
int numb;
cout<<"Please enter your input from 5 to 9";
cin>>numb;
if((numb <5)&&(numb>9))
cout<<"please re type your input";
else
for(i=0;i<=MAX; i++)
{
total = total + numb;
average= total /MAX;
}
cout<<"The average number is"<<
return 0;
}
Assignment Operator - What is the diffrence between a "assignment operator" and a "copy constructor"?
Answer: In assignment operator, you are assigning a value to an existing object. But in copy constructor, you are
creating a new object and then assigning a value to that object. 
For example:
complex c1,c2;
c1=c2; //this is assignment
complex c3=c2; //copy constructor

What will be printed as the result of the operation below:

main()
{
int x=20,y=35;
x=y++ + x++;
y= ++y + ++x;
printf(“%d%dn”,x,y);}
Answer : 5794

Explain the popular multiprocessor thread-scheduling strategies.

Answer:
Load Sharing: Processes are not assigned to a particular processor. A global queue of threads is
maintained. Each processor, when idle, selects a thread from this queue. Note that load balancing refers
to a scheme where work is allocated to processors on a more permanent basis.
Gang Scheduling: A set of related threads is scheduled to run on a set of processors at the same time,
on a 1-to-1 basis. Closely related threads / processes may be scheduled this way to reduce
synchronization blocking, and minimize process switching. Group scheduling predated this strategy.
Dedicated processor assignment: Provides implicit scheduling defined by assignment of threads to
processors. For the duration of program execution, each program is allocated a set of processors equal
in number to the number of threads in the program. Processors are chosen from the available pool.
Dynamic scheduling: The number of thread in a program can be altered during the course of execution.

What is a trap and trapdoor?

Answer:
Trapdoor is a secret undocumented entry point into a program used to grant access without normal
methods of access authentication. A trap is a software interrupt, usually the result of an error condition. 

What is time-stamping?

Answer:
It is a technique proposed by Lamport, used to order events in a distributed system without the use of
clocks. This scheme is intended to order events consisting of the transmission of messages. Each
system 'i' in the network maintains a counter Ci. Every time a system transmits a message, it increments
its counter by 1 and attaches the time-stamp Ti to the message. When a message is received, the
receiving system 'j' sets its counter Cj to 1 more than the maximum of its current value and the incoming receiving system 'j' sets its counter Cj to 1 more than the maximum of its current value and the incoming time-stamp Ti. At each site, the ordering of messages is determined by the following rules: For messages x from site i and y from site j, x precedes y if one of the following conditions holds....(a) if Ti<=""
blockquote="">

How are the wait/signal operations for monitor different from those for semaphores?

Answer:
If a process in a monitor signal and no task is waiting on the condition variable, the signal is lost. So this
allows easier program design. Whereas in semaphores, every operation affects the value of the
semaphore, so the wait and signal operations should be perfectly balanced in the program.
What you know about C++?
Released in 1985, C++ is an object-oriented programming language created by Bjarne Stroustrup. C++
maintains almost all aspects of the C language, while simplifying memory management and adding
several features - including a new datatype known as a class (you will learn more about these later) - to
allow object-oriented programming. C++ maintains the features of C which allowed for low-level memory
access but also gives the programmer new tools to simplify memory management.
C++ used for:
C++ is a powerful general-purpose programming language. It can be used to create small programs or
large applications. It can be used to make CGI scripts or console-only DOS programs. C++ allows you to
create programs to do almost anything you need to do. The creator of C++, Bjarne Stroustrup, has put
together a partial list of applications written in C++.

What is an object?

Answer: Object is a software bundle of variables and related methods. Objects have state and behavior.
What do you mean by inheritance?
Inheritance is the process of creating new classes, called derived classes, from existing classes or base
classes. The derived class inherits all the capabilities of the base class, but can add embellishments and
refinements of its own. What is polymorphism?
Polymorphism is the idea that a base class can be inherited by several classes. A base class pointer can
point to its child class and a base class array can store different child class objects.

44. What is a scope resolution operator?

Answer: A scope resolution operator (::), can be used to define the member functions of a class outside the class.
Anything wrong with this code?
T *p = new T[10];
delete p;
Everything is correct, Only the first element of the array will be deleted”, The entire array will be deleted,
but only the first element destructor will be called.

What is Boyce Codd Normal form?

Answer: A relation schema R is in BCNF with respect to a set F of functional dependencies if for all functional
dependencies in F+ of the form a-> , where a and b is a subset of R, at least one of the following holds:
* a- > b is a trivial functional dependency (b is a subset of a)
* a is a superkey for schema R

What is virtual class and friend class?

Answer: Friend classes are used when two or more classes are designed to work together and need access to
each other's implementation in ways that the rest of the world shouldn't be allowed to have. In other
words, they help keep private things private. For instance, it may be desirable for class DatabaseCursor
to have more privilege to the internals of class Database than main() has.

How do you find out if a linked-list has an end?
 (i.e. the list is not a cycle)
Answer: You can find out by using 2 pointers. One of them goes 2 nodes each time. The second one goes at 1
nodes each time. If there is a cycle, the one that goes 2 nodes each time will eventually meet the one that
goes slower.
If that is the case, then you will know the linked-list is a cycle.

What is the difference between realloc() and free()?

Answer: The free subroutine frees a block of memory previously allocated by the malloc subroutine. Undefined
results occur if the Pointer parameter is not a valid pointer. If the Pointer parameter is a null value, no
action will occur. The realloc subroutine changes the size of the block of memory pointed to by the
Pointer parameter to the number of bytes specified by the Size parameter and returns a new pointer to the
block. The pointer specified by the Pointer parameter must have been created with the malloc, calloc, or
realloc subroutines and not been deallocated with the free or realloc subroutines. Undefined results occur
if the Pointer parameter is not a valid pointer.

What is function overloading and operator overloading?

Answer: Function overloading: C++ enables several functions of the same name to be defined, as long as these
functions have different sets of parameters (at least as far as their types are concerned). This capability is
called function overloading. When an overloaded function is called, the C++ compiler selects the proper
function by examining the number, types and order of the arguments in the call. Function overloading is
commonly used to create several functions of the same name that perform similar tasks but on different
data types.
Operator overloading allows existing C++ operators to be redefined so that they work on objects of userdefined classes. Overloaded operators are syntactic sugar for equivalent function calls. They form a
pleasant facade that doesn't add anything fundamental to the language (but they can improve
understand ability and reduce maintenance costs).

What is the difference between declaration and definition?

Answer: The declaration tells the compiler that at some later point we plan to present the definition of this
declaration.
E.g.: void stars () //function declaration
The definition contains the actual implementation.
E.g.: void stars () // declarator
{
for(int j=10; j > =0; j--) //function body
cout << *;
cout <<>

What are the advantages of inheritance?

Answer: It permits code reusability. Reusability saves time in program development. It encourages the reuse of
proven and debugged high-quality software, thus reducing problem after a system becomes functional.
How do you write a function that can reverse a linked-list?
void reverselist(void)
{
if(head==0)
return;
if(head->next==0)
return;
if(head->next==tail)
{
head->next = 0;
tail->next = head;
}
else
{
node* pre = head;
node* cur = head->next;
node* curnext = cur->next;
head->next = 0;
cur-> next = head;
for(; curnext!=0; )
{
cur->next = pre;
pre = cur;
cur = curnext;
curnext = curnext->next;
}
curnext->next = cur;
}
}

What do you mean by inline function?

Answer: The idea behind inline functions is to insert the code of a called function at the point where the function is
called. If done carefully, this can improve the application's performance in exchange for increased
compile time and possibly (but not always) an increase in the size of the generated binary executables.
Write a program that ask for user input from 5 to 9 then calculate the average
#include "iostream.h"
int main() {
int MAX = 4;
int total = 0;

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More