All the OOPS vs. Procedural programming might mislead you to believe that OOP is totally unrelated to POP. That's not entirely true.
The confusion is further confounded by OOAD books that teach in abstract as in 'In procedural programming functions call functions. In OOP Objects pass messages to other objects'. What this really means is Objects call functions defined within their own class or in other classes!
Lets consider an example .
Procedural function call --
void f1(){
f2();
}
(so-called) OOP message passing
public class ClassA {
public void fnA()
{
ClassB objB = new ClassB();
objB.fnB(); fnA3();
}
public void fnA2() {
}
public void fnA3() {
}
}
public class ClassB {
public void fnB()
{
}
}
ClassA objA = new ClassA();
objA.fnA(); objA.fnA2();
As you can see from the above example, Objects do most of the work in OOPS. Objects need to be created (using 'new' operator) to be able call the functions (methods) on them. Once an object is created multiple functions can be called on it. An object can, not only call it's own classes function, but also create/and or call other objects [of same or different class] functions.
Though, at the outset, this style of programming might feel radically different, at a micro-level OOP is procedural too.
public class MyClass {
public void Myfunc() { f1(); f2(); f3(); }
private void f1() { // do stuff }
private void f2() { // do some other stuff }
private void f3() { // do some more stuff }
}
As you'd notice, implementation of Myfunc() is entirely procedural. Good thing about OOPS is that builds on best practices of POP, while eliminating it's limitations.