Wednesday 29 February 2012

What is the difference between text and binary modes?

Streams can be classified into two types: text streams and binary streams. Text streams are interpreted, with a maximum length of 255 characters. With text streams, carriage return/line feed combinations are translated to the newline \n character and vice versa. Binary streams are uninterpreted and are treated one byte at a time with no translation of characters. Typically, a text stream would be used for reading and writing standard text files, printing

Tuesday 28 February 2012

Sun Certified Java Programmer (SCJP) Questions

Which is the most suitable Java collection class for storing various companies and their stock prices? It is required that the class should support synchronization inherently.


Choices:

  • A. Hashtable

  • B. HashMap

  • C. LinkedHashMap

  • D. HashSet

  • E. TreeMap


Correct choice:

  • A


Explanation:

Monday 27 February 2012

Types of External Memory


  • Magnetic Disk


—   RAID


—   Removable




  • Optical


—   CD-ROM


—   CD-Recordable (CD-R)


—   CD-R/W


—   DVD




  • Magnetic Tape


Magnetic Disk



  • Disk substrate coated with magnetizable material (iron

Sunday 26 February 2012

What are the different phase/steps of acquiring a proxy object in Webservice ?

Following are the different steps needed to get a proxy object of a webservice at the client side :-

  • Client communicates to UDI node for WebService either through browser or UDDI's public web service.

  • UDII responds with a list of webservice.

  • Every service listed by webservice has a URI pointing to DISCO or WSDL document.

Saturday 25 February 2012

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

Thursday 23 February 2012

The Collections framework

List classes


A List is an ordered collection, which allows positional access and search.

The classes implementing List are ordered by index position. An ArrayList enables fast iteration and constant speed positional access. A Vector is similar to ArrayList, only slower because it is synchronized. LinkedList allows fast insertion and deletion at the beginning or end. It is commonly used for implementing stacks and queues. For instance:

Wednesday 22 February 2012

Virtual Memory


  • Demand paging


—   Do not require all pages of a process in memory


—   Bring in pages as required




  • Page fault


—   Required page is not in memory


—   Operating System must swap in required page


—   May need to swap out a page to make space

Tuesday 21 February 2012

What are the steps to create a webservice and consume it ?

Note :- For this question this post will make a attempt by creating a simple webservice and explaining steps to acheive it. A simple webservice will be created which takes two number and gives addition result of the two number. Definitely the interviewer will not expect such a detail answer but this book will explain you in detail so that you are on right track during interview.


This webservice will add two numbers and give to the calling client. All the below steps are according to VS2008 beta editor :-

  • First create a website by clicking on File -- New WebSite.

Monday 20 February 2012

Frequently Asked Questions in Technical Round at MNCs like TCS, WIPRO, INFOSYS,..etc – 10

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


1)

main()

{

char *str1="abcd";


char str2[]="abcd";


printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd"));


}

Answer:

2 5 5


Explanation:

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

Friday 17 February 2012

The Collections framework

Collections and collections interfaces


Collections are objects used to group together and manipulate multiple data elements. They can dynamically grow and shrink, which is their advantage over arrays. Collections provide methods to add objects to a collection, remove objects from it, check if an object is

Thursday 16 February 2012

Replacement Algorithms


  • Least Recently used (LRU)

  • e.g. in 2 way set associative

    • Which of the 2 block is lru?



  • First in first out (FIFO)

    • replace block that has been in cache longest



  • Least frequently used (LFU)

Wednesday 15 February 2012

What is a Web Service ?

Web Services are business logic components which provide functionality via the Internet using standard protocols such as HTTP.

Web Services uses Simple Object Access Protocol (SOAP) in order to expose the business functionality.SOAP defines a standardized format in XML which can be exchanged between two entities over

Tuesday 14 February 2012

Frequently Asked Questions in Technical Round at MNCs like TCS, WIPRO, INFOSYS,..etc – 9

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


1)

main()

{

char *cptr,c;


void *vptr,v;


c=10;  v=0;


cptr=&c; vptr=&v;


printf("%c%v",c,v);


}

Answer:

Compiler error (at line number 4): size of v is Unknown.


Explanation:

Monday 13 February 2012

What is hashing?

To hash means to grind up, and that’s essentially what hashing is all about. The heart of a hashing algorithm is a hash function that takes your nice, neat data and grinds it into some random-looking integer.

The idea behind hashing is that some data either has no inherent ordering (such as images) or is expensive to compare (such as images). If the data has no inherent ordering, you can’t perform comparison searches. If the data is expensive to compare, the

How many objects will be eligible for garbage collection after line 7?

public class TutorialGC
{

public static void main(String [] args)
{


Object a = new Integer(100);   // Line1
Object b = new Long(100);       // Line2
Object c = new String(“100″);  // Line3
a = null;                                        // Line4
a = c;                                             // Line5
c = b;                                             // Line6
b = a;                                             // Line7
// Rest of the code here


}


}

Choices:



  • A. 0

  • B. 1

  • C. 2

  • D. 3

  • E. Code does not compile


Correct choice:



  • B


Explanation:

Sunday 12 February 2012

Cache


  • Small amount of fast memory

  • Sits between normal main memory and CPU

  • May be located on CPU chip or module



Cache operation



  • CPU requests contents of memory location

  • Check cache for this data

Saturday 11 February 2012

What will be the result of an attempt to compile and run the following program?

class Test
{

public static void main(String args[])
{


String s1 = "abc";
String s2 = "abc";
s1 += "xyz";
s2.concat("pqr");
s1.toUpperCase();
System.out.println(s1 + s2);


}


}

Choices:

  • A. "abcxyzabc"

  • B. "abcxyzabcpqr"

  • C. "ABCXYZabcpqr"

  • D. "ABCXYZabc"

  • E. Code does not compile


Correct choice:

  •  A


Explanation:

Friday 10 February 2012

What is marshaling and what are different kinds of marshaling ?

Marshaling is used when an object is converted so that it can be sent across the network or across application domains. Unmarshaling creates an object from the marshaled data.
There are two ways to do marshaling :-

  • Marshal-by-value (MBV) :- In this the object is serialized into the channel, and a copy of the object is created on the other side

Thursday 9 February 2012

Frequently Asked Questions in Technical Round at MNCs like TCS, WIPRO, INFOSYS,..etc – 8

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


1)

int i,j;

for(i=0;i<=10;i++)

{

j+=5;


assert(i<5);


}

Answer:

Runtime error: Abnormal program termination.


assert failed (i<5), <file name>,<line number>


Explanation:

Wednesday 8 February 2012

What is the quickest searching method to use?

A binary search, such as bsearch() performs, is much faster than a linear search. A hashing algorithm can provide even faster searching. One particularly interesting and fast method for searching is to keep the data in a “digital trie.” A digital trie offers the prospect of being able to search for an item in essentially a constant amount of time, independent of how many items are in the data set.

A digital trie combines aspects of binary searching, radix searching, and hashing. The term “digital trie” refers to the data structure used to hold the items to be searched. It is a multilevel data structure that

Tuesday 7 February 2012

Memory Hierarchy


  • Registers


—   In CPU




  • Internal or Main memory


—   May include one or more levels of cache


—   “RAM”




  • External memory

Monday 6 February 2012

Wrapper classes

Wrapper classes correspond to the primitive data types in the Java language. These classes represent the primitive values as objects. All the wrapper classes except Character have two constructors -- one that takes the primitive value and another that takes the String representation of the value. For instance:

Integer i1 = new Integer(50);
Integer i2 = new Integer("50");


The Character class constructor takes a char type element as an

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

Saturday 4 February 2012

Frequently Asked Questions in Technical Round at MNCs like TCS, WIPRO, INFOSYS,..etc – 7

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


1)

main ( )

{

 static char *s[ ]  = {“black”, “white”, “yellow”, “violet”};


 char **ptr[ ] = {s+3, s+2, s+1, s}, ***p;


 p = ptr;


 **++p;


 printf(“%s”,*--*++p + 3);


}

Answer:

ck


Explanation:

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

Thursday 2 February 2012

Read Only Memory (ROM)


  • Permanent storage


—   Nonvolatile




  • Microprogramming (see later)

  • Library subroutines

  • Systems programs (BIOS)

  • Function tables


Types of ROM



  • Written during manufacture


—   Very expensive for small runs




  • Programmable (once)

Wednesday 1 February 2012

String and StringBuffer

Immutability of String objects


As you know, Strings are objects in Java code. These objects, however, are immutable. That is, their value, once assigned, can never be changed. For instance:

String msg = "Hello";
msg += " World";


Here the original String "Hello" is not changed. Instead, a new String is created with the value "Hello World" and assigned to the variable