Monday 30 January 2012

What are LeaseTime, SponsorshipTime, RenewonCallTime and LeaseManagerPollTime?

This is a very important question from practical implementation point of view. Companies who have specific requirement for Remoting projects will expect this question to be answered.


In normal .NET environment objects lifetime is managed by garbage collector. But in remoting environment remote clients can access objects which are out of control of garbage collector. Garbage collector boundary is limited to a single PC on which framework is

Sunday 29 January 2012

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

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


1)

main( )

{

 void *vp;


 char ch = ‘g’, *cp = “goofy”;


 int j = 20;


 vp = &ch;


 printf(“%c”, *(char *)vp);


 vp = &j;


 printf(“%d”,*(int *)vp);


 vp = cp;


 printf(“%s”,(char *)vp + 3);


}

Answer:

g20fy


Explanation:

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

Friday 27 January 2012

Thursday 26 January 2012

Fundamental classes in the java.lang package

Using the Math class


The Math class is final and all the methods defined in the Math class are static, which means you cannot inherit from the Math class and override these methods. Also, the Math class has a private constructor, so you cannot instantiate it.

The Math class has the following methods: ceil(), floor(), max(),

Wednesday 25 January 2012

In CAO model for client objects to be created by “NEW” keyword what should we do?

Remoting Clients and Remoting Server can communicate because they share a common contract by implementing Shared Interface or Base Class (As seen in previous examples). But according to OOP’s concept we can not create a object of interface or Base Classes (Abstract Class). Shipping the server object to client is not a good design practice. In CAO model we can use SOAPSUDS utility to generate Metadata DLL from server which can be shipped to client, clients can then use this DLL for creating object on server. Run the

Tuesday 24 January 2012

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

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


1)

main( )

{

 static int  a[ ]   = {0,1,2,3,4};


 int  *p[ ] = {a,a+1,a+2,a+3,a+4};


 int  **ptr =  p;


 ptr++;


 printf(“\n %d  %d  %d”, ptr-p, *ptr-a, **ptr);


 *ptr++;


 printf(“\n %d  %d  %d”, ptr-p, *ptr-a, **ptr);


 *++ptr;


 printf(“\n %d  %d  %d”, ptr-p, *ptr-a, **ptr);


 ++*ptr;


printf(“\n %d  %d  %d”, ptr-p, *ptr-a, **ptr);


}

Answer:

111


222


333


344


Explanation:

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

Sunday 22 January 2012

Pipelining


  • Fetch instruction

  • Decode instruction

  • Calculate operands (i.e. EAs)

  • Fetch operands

  • Execute instructions

  • Write result

  • Overlap these operations


Two Stage Instruction Pipeline


Pentium 4 Cache



  • Pentium (all versions) – two on chip L1 caches


—   Data & instructions

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

Friday 20 January 2012

Describe in detail Basic of SAO architecture of Remoting?

For these types of questions interviewer expects small and sweet answers. He is basically looking at what you know about the specific subject. For these type of question this post will provide detail code which is not necessary to be said during interview. Only the basic steps and overall brief are enough to convince that you have knowledge about the subject. Even though this question has detail code and answer say only what is needed in interview.


Remoting has at least three sections :-

  • Common Interface which will be shared between them.

  • Server.

  • Client.


Solution Explorer of Remoting Project


Above is the figure which shows the three important project

Thursday 19 January 2012

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

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


1)

main( )

{

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


printf(“%u %u %u %d \n”,a,*a,**a,***a);


printf(“%u %u %u %d \n”,a+1,*a+1,**a+1,***a+1);


}

Answer:

100, 100, 100, 2


114, 104, 102, 3


Explanation:

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 15 January 2012

Instruction Cycle with Indirect

Indirect Cycle



  • May require memory access to fetch operands

  • Indirect addressing requires more memory accesses

  • Can be thought of as additional instruction subcycle


Instruction Cycle with Indirect



Instruction Cycle State Diagram

Saturday 14 January 2012

Threads in Java – 2

Thread states


Threads can be in one of the following states:

New. After the thread is instantiated, the thread is in the New state until the start()method is invoked. In this state, the thread is not considered alive.

Runnable. A thread comes into the runnable state when the start() method is invoked on it. It can also enter the runnable state from the running state or blocked state. The thread is considered alive when it is in this state.

Running. A thread moves from the runnable state into the running state when the thread scheduler chooses it to be the currently running thread.

Alive, but not runnable. A thread can be alive but not in a runnable state for a variety

What is an application domain ?

Previously “PROCESS” where used as security boundaries. One process has its own virtual memory and does not over lap the other process virtual memory; due to this one process can not crash the other process. So any problem or error in one process does not affect the other process. In .NET they went one step ahead introducing application domains. In application domains multiple applications can run in same process with out influencing each other. If one of the application domains throws error it does not affect the other application domains. To invoke method in a object running in different application domain .NET remoting is used.

 One process can have multiple Application domains



What is .NET Remoting ?


.NET remoting is replacement of DCOM. Using .NET remoting you can make remote object

Thursday 12 January 2012

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

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


1)

#include<stdio.h>

main()

{

struct xx


{


int x=3;


char name[]="hello";


};


struct xx *s=malloc(sizeof(struct xx));


printf("%d",s->x);


printf("%s",s->name);


}

Answer:

Compiler Error


Explanation:

Tuesday 10 January 2012

CPU Structure


  • CPU must:


—   Fetch instructions


—   Interpret instructions


—   Fetch data


—   Process data


—   Write data



CPU With Systems Bus


CPU Internal Structure

Monday 9 January 2012

Threads in Java - 1

Creating threads


Threads are objects in the Java language. A thread can be defined by extending the java.lang.Thread class or by implementing the java.lang.Runnable interface. The run() method should be overridden and should have the code that will be executed by the new thread. This method must be public with a void return type and should not take any arguments.

Extending thread


If we need to inherit the behavior of the Thread class, we can have a subclass of it. In this case, the disadvantage is that you cannot extend

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

Saturday 7 January 2012

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

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


1)

#include<stdio.h>

main()

{

  char s[]={'a','b','c','\n','c','\0'};


  char *p,*str,*str1;


  p=&s[3];


  str=p;


  str1=s;


  printf("%d",++*p + ++*str1-32);


}

Answer:

M


Explanation:

Friday 6 January 2012

DotNet Frequently Asked Questions on Threading – 3

What are wait handles ?


Wait handles sends signals of a thread status from one thread to other thread. There are three kind of wait modes :-

  • WaitOne.

  • WaitAny.

  • WaitAll.


When a thread wants to release a Wait handle it can call Set method. You can use Mutex (mutually exclusive) objects to avail for the following modes. Mutex objects are synchronization objects that can only be owned by a single thread at a time. Threads request ownership of the mutex object when they require exclusive access to a resource. Because only one thread can own a mutex object at any time, other threads must wait for ownership of a mutex object before using the resource.

The WaitOne method causes a calling thread to wait for ownership of

Thursday 5 January 2012

Addressing Modes


  • Immediate

  • Direct

  • Indirect

  • Register

  • Register Indirect

  • Displacement (Indexed)

  • Stack


Immediate Addressing



  • Operand is part of instruction

  • Operand = address field

  • e.g. ADD 5


—   Add 5 to contents of accumulator


—   5 is operand




  • No memory reference to fetch data

  • Fast

  • Limited range


Direct Addressing



  • Address field contains address of operand

  • Effective address (EA) = address field (A)

Wednesday 4 January 2012

Sun Certified Java Programmer (SCJP) Questions

Which of the choices below can legally be inserted at the "insert code here" position in the following code?


class Parent
{


public void print(int i)


{
}


}


public class Child extends Parent
{


public static void main(String argv[])
{
}


// insert code here


}


Choices:

A. public void print(int i, byte b) throws Exception {}


B. public void print(int i, long i) throws Exception {}


C. public void print(long i) {}


D. public void print(int i) throws Exception {}


E. public int print(int i)


Correct choices:

A, B, and C


Explanation:

Tuesday 3 January 2012

What is the easiest sorting method to use?

The answer is the standard library function qsort(). It’s the easiest sort by far for several reasons:

It is already written.
It is already debugged.
It has been optimized as much as possible (usually).


The algorithm used by qsort() is generally the quick sort algorithm, developed by C. A. R. Hoare in 1962.

Here is the prototype for qsort():

void qsort(void *buf, size_t num, size_t size,

int (*comp)(const void *ele1, const void *ele2));


The qsort() function takes a pointer to an array of user-defined data (buf). The array has num elements in it, and each element is size bytes long. Decisions about sort order are made by calling comp,

Monday 2 January 2012

Frequently Asked Questions in Technical Round at MNCs like TCS, WIPRO, INFOSYS,..etc - 1

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


1)

main()

{

static char names[5][20]={"pascal","ada","cobol","fortran","perl"};


int i;


char *t;


t=names[3];


names[3]=names[4];


names[4]=t;


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


printf("%s",names[i]);


}

Answer:

Compiler error: Lvalue required in function main


Explanation:

Sunday 1 January 2012

DotNet Frequently Asked Questions on Threading - 2

What are Daemon threads and how can a thread be created as Daemon?


Daemon thread's run in background and stop automatically when nothing is running program. Example of a Daemon thread is "Garbage collector". Garbage collector runs until some .NET code is running or else its idle.
You can make a thread Daemon by
Thread.Isbackground=true

When working with shared data in threading how do you implement synchronization ?


There are certain situtations that you need to be careful with when using threads. If two threads (e.g. the main and any worker threads) try to access the same variable at the same time, you'll have a problem. This can be very difficult to debug because they may not always do it at exactly the same time. To avoid the problem, you can