Thursday, February 28, 2013

Java and .NET Referal Openings At Infosys

Hi All,

There is scheduled Recruitment drive for Referals who are short-listed on March 16th in across all locations in Infosys.
Please send u r resumes to this id:  sambamca06@gmail.com
Exp Range: 2 to 8 yrs

Note: Please send only genuine profiles.

Wednesday, February 27, 2013

Difference between Abstract class and Interface

Abstract Class
==========
1.An abstract class can have method body (non-abstract methods).
2.An abstract class can have instance variables.
3.An abstract class can have constructor.
4.An abstract class can have static methods.
5.You can extends one abstract class.

ex:
publlic abstract class TxnCommand
{

public abstract void  show();

public void calculate()
{
//Method Implimentatiion;
}

}

Interface
=======
1.Interface have only abstract methods.
2.An interface cannot have instance variables.
3.Interface cannot have constructor.
4.Interface cannot have static methods.
5.You can implement multiple interfaces.

ex:


public
interface CommonCommand
{

public static final int i = 10;
public abstract void  show();

}

difference between static method and instance method in Java

Static Method:
===========
1.A method i.e. declared as static is known as static method.
2.Object is not required to call static method.
3.Non-static (instance) members cannot be accessed in static context (static method, static block and static nested class) directly.
4.For example: public static void show(){..... }.


Instance Method:
============
1.A method i.e. not declared as static is known as instance method.
2.Object is required to call instance methods.
3.static and non-static variables both can be accessed in instance methods.
4.For example: public void show(){...}.


 

Tuesday, February 19, 2013

System.out.println() In Java?

 In Java, the dot operator can only be used to call methods and variables so we know that ‘out’ must be either a method or a variable. Now, how do we categorize ‘out’? Well, ‘out’ could not possibly be a method because of the fact that there are no parentheses – the ‘( )’ – after ‘out’, which means that out is clearly not a method that is being invoked. And, ‘out’ does not accept any arguments because only methods accept arguments – you will never see something like “System.out(5,6).println”. This means ‘out’ must be a variable.

We now know that ‘out’ is a variable, so we must now ask ourselves what kind of variable is it? There are two possibilities – it could be a static or an instance variable. Because ‘out’ is being called with the ‘System’ class name itself, and not an instance of a class (an object), then we know that ‘out’ must be a static variable, since only static variables can be called with just the class name itself. So now we know that ‘out’ is a static member variable belonging to the System class.

The fact that ‘println()’ is clearly a method, we can further classify ‘out’. We have already reasoned that ‘out’ is a static variable belonging to the class System. But now we can see that ‘out’ must be an instance of a class, because it is invoking the method ‘println()’.

When the JVM is initialized, the method initializeSystemClass() is called that does exactly what it’s name says – it initializes the System class and sets the out variable. The initializeSystemClass() method actually calls another method to set the out variable – this method is called setOut().

The more exact answer to the original question is this: inside the System class is the declaration of ‘out’ that looks like: ‘public static final PrintStream out’, and inside the Prinstream class is a declaration of ‘println()’ that has a method signature that looks like: ‘public void println()’.

Here is what the different pieces of System.out.println() actually look like:
//the System class belongs to java.lang package
class System {
  public static final PrintStream out;
  //...
}

//the Prinstream class belongs to java.io package
class PrintStream{
public void println();
//...
}

Tuesday, February 12, 2013

Valentine day special greetins























Scope of Static variables


Static variables cannot be elected for garbage collection while the class is loaded. They can be collected when the respective class loader (that was responsible for loading this class) is itself collected for garbage.