Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What`s the benefit of writing the code in a way below: or what should i learn to understand it? give me some link to some tutorials plz. thx)))

class ClassOne implements SomeInterface {
   ClassTwo  ct = new ClassTwo ();
   public boolean someMethod(){
         return ct.someMethod();
   }

    public static void main(String[] args) {
    }
}


interface SomeInterface {
	boolean someMethod();
}


class ClassTwo implements SomeInterface {
	public boolean someMethod()	{
	    return true;
	}
}


What I have tried:

read about delegation inheritance encapsulation
Posted
Updated 13-Feb-18 22:20pm
Comments
PIEBALDconsult 13-Feb-18 23:10pm    
You need to master the fundamentals first.

Well, in order to understand as to what's happening in the above code just spend some time on the basics of OOP first or if you have a bit of background of it and are still not able to grasp it then, I'd recommend that you get Kathy Sierra's SCJP complete guide the best would be to get of java se 8. But if you're not willing to spend to get it here's a reference for java se 6 https://iamgodsom.files.wordpress.com/2014/08/scjp-sun-certified-programmer-for-java-6-0071591060.pdfpdf.
Spend some time reading it properly and most of your doubts would get cleared after 1 or 2 readings.
Hope this helps.
 
Share this answer
 
The above code shows all the concepts you mentioned.
You have to grasp both the OOP principles and the Java programming language in order to understand the code.
 
Share this answer
 
Go to The Java™ Tutorials[^], where all these concepts are clearly explained.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900