Oops concept with real world example and with code ?

hare singh nayak

hare singh nayak

@hare-singh-nayak-WEmcz0 Oct 26, 2024
hi friends

i have faced three interview and oops concepts are asked there with the real life example and implement in coding. i told them all concept theoretically but could not implemented practically and because of that i was not selected . so please explain me oops concept with practical example. so it would be more helpful for me and other crazyengeers.

thank you in advance

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Anoop Kumar

    Anoop Kumar

    @anoop-kumar-GDGRCn Aug 16, 2013

    There are numbers of concepts on which interviewer would have asked you for practical example.
    Let's start one by one.
    Tell what was the question and what you have answered?
    I am sure people here will answer you in detail and your counter questions.

    Do not shy everyone is crazy here😨
  • rahul69

    rahul69

    @rahul69-97fAOs Aug 16, 2013

    hare singh nayak
    hi friends

    i have faced three interview and oops concepts are asked there with the real life example and implement in coding. i told them all concept theoretically but could not implemented practically and because of that i was not selected . so please explain me oops concept with practical example. so it would be more helpful for me and other crazyengeers.

    thank you in advance
    As iAnoop said, it is better if u can give question which were asked and what u answer, so that a healthy discussion can be carried out on it.
    But still, I will give u an example:
    Suppose in real life I take a ball as an object (classical example 😉 ).
    In real life ball has attributes (size, weight, color etc.) and behaviour (bounces, squeezes etc. ).
    Similarly in programming u can implement it by:
    • Creating a class ball which creates objects of ball type
    • Creating instance variables in class as size, weight etc. to represent attributes (or u may call it as state).
    • Creating functions (or methods 😁 ) eg. bounces , squeezes etc. to represent it's behaviour.
    • And different types of constructors ( as per need 😛 )
    As class is ready, simply create objects of ball class and call functions as per need, and u have a practical example of OOPS concepts,
    NOTE: Do keep in mind to mention other Oops concepts which are to be implemented, eg. How encapsulation and abstraction are working in this example(more on this later),
    but first tell what questions u actually faced and how u faced those ☕
  • Nayan Goenka

    Nayan Goenka

    @nayan-Dhpt4N Aug 16, 2013

    This is a good example of OOPs concept. OOP is all about defining things with the point of view of its attributes, behavior, its functions and its utility. If you can fit anything in this, it can be quantified as application of OOPs