To pass as argument in the constructor call

We can pass the this keyword in the constructor also. It is useful if we have to use one object in multiple classes. Let's see the example:


\begin{lstlisting}
class B{
A4 obj;
B(A4 obj){
this.obj=obj;
}
void di...
...ublic static void main(String args[]){
A4 a=new A4();
}
}
\end{lstlisting}

The output for the above snippet will be 10.