Posted by: ahmedashfaque | February 1, 2015

object oriented programming puzzle

I have a small puzzle for you. I have a piece of code where I create objects from a class and do some assignments. Please find out solution of the computation done in this code. Also find out the reason for the solution.

public class a {

int count = 0;


public class b{

public static void main (String[] args){

a e1 = new a();

a e2 = new a();

int x = 4;

e1.count = x;


e2.count = e2.count + 1;




Tomorrow I will provide the solution with explanation.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: