Java Interview questions on OOP Concepts

Categories: OTHERS

Q.1. What is the difference between loose coupling and tight coupling?

Loose coupling allows components to interact with each other with minimal dependencies, while tight coupling creates strong dependencies between components.

 

Q.2. What is the difference between cohesion and coupling?

Cohesion refers to the degree to which elements within a module belong together, while coupling refers to the degree of interdependence between modules.

 

Q.3. What is Liskov Substitution principle? Can you explain with an example?

Liskov Substitution principle states that objects of a superclass should be replaceable with objects of its subclasses without affecting the correctness of the program.

For example, In a class hierarchy where "Shape" is the superclass and "Circle" and "Square" are the subclasses, every method that functions on Shape should also function correctly on Circle or Square.

 

Q.4. What is the difference between abstract class and interface in Java?

Abstract classes can have both abstract and concrete methods, while interfaces can only have abstract methods. Additionally, a class can implement multiple interfaces but can only extend one abstract class.

 

Q.5. What is the difference between composition, aggregation, and association?

Composition: Composition implies a strong ownership relationship where the lifetime of the contained object is dependent on the container.

Aggregation: Aggregation implies a weaker relationship where the contained object can exist independently of the container. 

Association: Association implies a relationship between two classes without any ownership or lifecycle dependency.

Top articles
What is the Red Data Book Published at:- kia review india Published at:- Understanding the Role of NATO Countries in Global Security Published at:- Tips for Acing the USMLE Exam on Your First Try Published at:- The Importance of Mock Exams for FRCS Exam Preparation Published at:- The Pros and Cons of Liquid vs. Pencil Eye Liner Published at:- Shardiya Navratri 2023: Know Date, Schedule, Muhurat and method of worship (Pooja Vidhi) Published at:- Navratri Fashion 2023: Latest Trends and Styling Tips Published at:- Navratri Fasting Guide: Tips for a Healthy and Spiritual Journey Published at:- Navratri Captivating Rangoli Designs to Add Charm to Your Celebrations Published at:- Navratri 2023: Embracing the Spirit of Garba and Dandiya Raas Published at:- Diwali Sweets and Treats: Delicious Recipes for the Festive Season Published at:- The Significance of Diwali: Celebration of Light and Goodness Published at:- Diwali Traditions: Exploring the Customs and Rituals Published at:- Delicious Diwali Delights: Recipes to Savor During the Festival of Lights Published at:- Celebrities and Diwali: Unveiling the Glamorous Celebrations Published at:- The Evolution of Santa Claus: From Saint Nicholas to Modern Icon Published at:- How to Decorate Your Christmas Tree: The ultimate guide Published at:- Christmas at Disneyland: A Magical Holiday Experience Published at:- The History and Symbolism behind the Christmas Jingle Bell Tradition Published at:- ICSE board exam 2024: Subjects, Syllabus, and Important Topics Published at:- The Board Exam Countdown: Last-Minute Preparation Strategies Published at:- Discovering the Sun's Secrets: An Extensive Look at NASA's Risky Missions Published at:- International Girl Child Day: Empowering Tomorrow's Leaders Published at:- Inspiring Republic Day Quotes to Ignite Your Patriotism: Echoes of India's Spirit Published at:- Teaching Children the Importance of Republic Day: Fun and Educational Activities Published at:- Beyond the Stars: 6 Unforgettable Astronomical Events to Witness in March 2024 Published at:- Embracing Rejection as a Stepping Stone to Success Published at:- 5 Green Initiatives to Support on World Environment Day 2024 Published at:- Green Highway Signs: Enhancing Driver Awareness in 2024 Published at:- Java Interview questions on OOP Concepts Published at:- NEET (Zoology MCQs) Published at:- NEET BOTANY MCQs (Morphology of flowering plants) Published at:- August, 2024 (Current Affairs MCQs) Published at:- Important Days and Events (MCQs) Published at:- Environment & Biodiversity (MCQs) Published at:-