aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Is it not against OO concept? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Is it not against OO concept?" Watch "Is it not against OO concept?" New topic
Author

Is it not against OO concept?

Geethakrishna Srihari
Ranch Hand

Joined: May 25, 2005
Posts: 30
The following code compiles:
class A
{
private int i;
public void modifyOther(A a1)
{
a1.i = 20;
}
}

The object has permission to use other object's private member ; it might be of same class - but is it not against OO? But this code compiles?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

Encapsulation in Java is class-based, not object based. C++ is the same way. Some languages -- Ruby, and Python, I think, too -- have object-based encapsulation. I don't think one is more object-oriented than the other, really.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it not against OO concept?
 
Similar Threads
Declaration before read Rule in Initializers
garbage collection
Question on inheritance
Array increment
Polymorphism