Showing posts with label Viva Voce. Show all posts
Showing posts with label Viva Voce. Show all posts

Friday, 11 January 2013

Floating point representation

The floating point representation of a number has two parts. The first part represents a signed, fixed point number called the mantissa. The second point designates the position of the decimal point and is called as the exponent. The fixed mantissa may be a

Saturday, 15 December 2012

List four significant differences between a file-processing system and a DBMS.

Answer: Some main differences between a database management system and a file-processing system are:

  • Both systems contain a collection of data and a set of programs which access that data. A database management system coordinates both the physical and the logical access to the data, whereas a file-processing system coordinates only the physical

Monday, 5 March 2012

How do you list files in a directory?

Unfortunately, there is no built-in function provided in the C language such as dir_list() that would easily provide you with a list of all files in a particular directory. By utilizing some of C’s built-in directory functions, however, you can write your own dir_list() function.

First of all, the include file dos.h defines a structure named find_t, which represents the structure of the DOS file entry block. This

Friday, 24 February 2012

How can you restore a redirected standard stream?

The preceding example showed how you can redirect a standard stream from within your program. But what if later in your program you wanted to restore the standard stream to its original state? By using the standard C library functions named dup() and fdopen(), you can restore a standard stream such as stdout to its original state.

The dup() function duplicates a file handle. You can use the dup() function to save the file handle corresponding to the stdout standard

Sunday, 19 February 2012

If errno contains a nonzero number, is there an error?

The global variable errno is used by many standard C library functions to pass back to your program an error code that denotes specifically which error occurred. However, your program should not check the value of errno to determine whether an error occurred.

Usually, the standard C library function you are calling returns with a return code which denotes that an error has occurred and that the

Sunday, 5 February 2012

Which config file has all the supported channels/protocol ?

Machine.config file has all the supported channels and formatter supported by .NET remoting.Machine.config file can be found at “C:\WINDOWS\Microsoft.NET\Framework\vXXXXX\CONFIG” path. Find <system.runtime.remoting> element in the Machine.config file which has the channels and the formatters. Below is a figure shown which can give a clear idea of how the file looks like.

Note :- Interviewer will not ask you to name all channels and

Friday, 3 February 2012

What is the easiest searching method to use?

Just as qsort() was the easiest sorting method, because it is part of the standard library, bsearch() is the easiest searching method to use.

Following is the prototype for bsearch():

void *bsearch(const void *key, const void *buf, size_t num, size_t size, int (*comp)(const void *, const void *));


The bsearch() function performs a binary search on an array of sorted data elements. A binary search is another “divide and conquer” algorithm. The key is compared with the middle element of

Saturday, 28 January 2012

How can I sort things that are too large to bring into memory?

A sorting program that sorts items that are on secondary storage (disk or tape) rather than primary storage (memory) is called an external sort. Exactly how to sort large data depends on what is meant by “too large to fit in memory.” If the items to be sorted are themselves too large to fit in memory (such as images), but there aren’t many items, you can keep in memory only the sort key and a

Monday, 23 January 2012

The Radix Sort

The radix sort shown below takes a list of integers and puts each element on a smaller list, depending on the value of its least significant byte. Then the small lists are concatenated, and the process is repeated for each more significant byte until the list is sorted. The radix sort is simpler to implement on fixed-length data such as ints, but it is illustrated here using strings.

Two functions perform the radix sort. The function radixSort() performs one pass through the data, performing a partial sort. Line

Saturday, 21 January 2012

Sun Certified Java Programmer (SCJP) Questions

Which of the following statements is not true about threads ?


Choices:



  • A. If the start() method is invoked twice on the same Thread object, an exception is thrown at runtime.

  • B. The order in which threads were started might differ from the order in which they actually run.

  • C. If the run() method is directly invoked on a Thread object, an

Tuesday, 17 January 2012

The Merge Sort

The merge sort is a “divide and conquer” sort as well. It works by considering the data to be sorted as a sequence of already-sorted lists (in the worst case, each list is one element long). Adjacent sorted lists are merged into larger sorted lists until there is a single sorted list containing all the elements. The merge sort is good at sorting lists and other data structures that are not in arrays, and it can be used to sort things that don’t fit into memory. It also can be implemented as a stable sort. The merge sort was suggested by John von Neumann in 1945!

Below example shows an implementation of the merge sort algorithm. To make things more interesting, the strings will be put into a linked list structure rather than an array. In fact, the algorithm works better on data that is organized as lists, because elements in an array cannot be merged in place (some extra storage is required).

There are four functions that together implement merge sort. The function split() takes a list of strings and turns it into a list of lists of

Sunday, 8 January 2012

What is the quickest sorting method to use?

The answer depends on what you mean by quickest. For most sorting problems, it just doesn’t matter how quick the sort is because it is done infrequently or other operations take significantly more time anyway. Even in cases in which sorting speed is of the essence, there is no one answer. It depends on not only the size and nature of the data, but also the likely order. No algorithm is best in all cases.

There are three sorting methods in this author’s “toolbox” that are all very fast and that are useful in different situations. Those methods are quick sort, merge sort, and radix sort.

The Quick Sort


The quick sort algorithm is of the “divide and conquer” type. That means it works by reducing a sorting problem into several easier sorting problems and solving each of them. A “dividing” value is chosen from the input data, and the data is partitioned into three sets: elements that belong before the dividing value, the value itself, and elements that come after the dividing value. The partitioning is

Friday, 18 November 2011

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

void main()

{

int a, *pa, &ra;


pa = &a;


ra = a;


cout <<"a="<<a <<"*pa="<<*pa <<"ra"<<ra ;


}

Answer :

Compiler Error: 'ra',reference must be initialized


Explanation :

Monday, 14 November 2011

How Gateway is different from Routers?

A gateway operates at the upper levels of the OSI model and translates information between two completely different network architectures or data formats.

A router is a device in computer networking that forwards data packets to their destinations, based on their addresses.

What is passive topology?

When the computers on the network simply listen and receive the signal, they are referred to as passive because they don’t amplify the signal in any way. Example for passive topology - linear bus.

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

class base

{

        public:


            virtual void baseFun(){ cout<<"from base"<<endl;}


        };

class deri:public base

{

        public:


            void baseFun(){ cout<< "from derived"<<endl;}


        };

void SomeFunc(base *baseObj)

{

        baseObj->baseFun();


}

int main()

{

base baseObject;


SomeFunc(&baseObject);


deri deriObject;


SomeFunc(&deriObject);


}

Answer:

            from base


            from derived


Explanation:

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

class base

{

public:


void baseFun(){ cout<<"from base"<<endl;}


};

class deri:public base

{

public:


void baseFun(){ cout<< "from derived"<<endl;}


};

void SomeFunc(base *baseObj)

{

baseObj->baseFun();


}

int main()

{

base baseObject;


SomeFunc(&baseObject);


deri deriObject;


SomeFunc(&deriObject);


}

Answer:

from base


from base


Explanation:

Friday, 11 November 2011

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

#include<stdio.h>

main()

{

int a[2][2][2] = { {10,2,3,4}, {5,6,7,8}  };


int *p,*q;


p=&a[2][2][2];


*q=***a;


printf("%d----%d",*p,*q);


}

Answer:

SomeGarbageValue---1

Explanation:

Tuesday, 8 November 2011

Can a variable be both const and volatile?

Yes. The const modifier means that this code cannot change the value of the variable, but that does not mean that the value cannot be changed by means outside this code. For instance, in the above example, the timer structure was accessed through a volatile const pointer. The function itself did not change the value of the timer, so it

When should the volatile modifier be used?

The volatile modifier is a directive to the compiler’s optimizer that operations involving this variable should not be optimized in certain ways. There are two special cases in which use of the volatile modifier is desirable. The first case involves memory-mapped hardware (a device such as a graphics adaptor that appears to the computer’s hardware as if it were part of the computer’s memory), and the second involves shared memory (memory used by two or more programs running simultaneously).

Most computers have a set of registers that can be accessed faster than the computer’s main memory. A good compiler will perform a