Forums Register Login

OOP Concepts

+Pie Number of slices to send: Send
Hi,

How to demonstrate all OOPs concepts in a Singal Java program file.

Regards,

Girish
+Pie Number of slices to send: Send
Basic OOP concepts are inheritance, encapsulation and polymorphism. To establish inheritance and polymorphism (without interfaces) you require two java classes. Try to read about the concepts and you can write them in one .java file.
+Pie Number of slices to send: Send
McGraw.Hill.Java.The.Complete.Reference.7th.Edition.Dec.2006 is really a good book for basic concepts. Author has done a tremondous job in explaining basic Java Concepts.
+Pie Number of slices to send: Send
 

Girish Havaldar wrote:How to demonstrate all OOPs concepts in a Singal Java program file.


What do you consider "all" OOP concepts?

As with any program, the first step is to define your requirements. The above gives a loose idea, but is FAR from a spec...
+Pie Number of slices to send: Send
 

Girish Havaldar wrote:How to demonstrate all OOPs concepts in a Singal Java program file.


I suggest you start here. There may even be examples you can use.

Winston
+Pie Number of slices to send: Send
Abstraction and modularization are also OOP concepts, and all these can be done in one file (with multiple classes). I will attempt a basic explanation how each OOP concept is applicable. Consider an Employee class file Employee.java:



As you can see, it has private methods that are only accessible from an external class by using it's public methods. This demonstrates encapsulation (information hiding). Also notice how the code shows abstraction, with the Employee class made of variables illustrating its properties and methods illustrating behavior. If we want to double the salary, we have a specific method for that purpose only, showing modularization.

The non-public class 'Programmer' in the same file extends 'Employee' class showing inheritance. It is left on the reader to write an interface and demonstrate polymorphism.
+Pie Number of slices to send: Send
 

Zeeshan Sheikh wrote:McGraw.Hill.Java.The.Complete.Reference.7th.Edition.Dec.2006 is really a good book for basic concepts. Author has done a tremondous job in explaining basic Java Concepts.

If that is Herbert Schild, in my opinion that book moves too fast to be of use to beginners.
+Pie Number of slices to send: Send
 

Campbell Ritchie wrote:

Zeeshan Sheikh wrote:McGraw.Hill.Java.The.Complete.Reference.7th.Edition.Dec.2006 is really a good book for basic concepts. Author has done a tremondous job in explaining basic Java Concepts.

If that is Herbert Schild, in my opinion that book moves too fast to be of use to beginners.



And though I haven't read it, I've heard Shildt's book is full of misinformation.
+Pie Number of slices to send: Send
I think misinformation is an exaggeration. It did have the errors I look for when I review a book eg about Scanner#nextLine() and the %n tag. I would have preferred to see OO concepts earlier in the book. Not a book I consider suitable for beginners, however, because of its fast pace.
Nothing up my sleeve ... and ... presto! A tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1871 times.
Similar Threads
StringBuffer problem
Messaging...
oops concepts
Some questions on servlet connected to mysql
tool to measure how many domain concepts
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:30:05.