Hi, welcome back. Now in this practical exercise, we will be learning a set of keywords that help us identify relationship between classes and objects. So here we need to just write up class here. Just create a class animal provide apprentices and we can create a class of different trades. We have just mammals that extends animals the us money to charity, or subset of animals. So really, we could create a different method constructors are arguments in each class.
And then we can create another class as well. Save public class Okay, it extends mallas This is the main class here because we have made it public. Now let us create a public static void Main, the main block and create an object objects from those classes. And then once mammal and cat and with the objects we could identify whether if an object is an instance of which class we could check. For instance of object is useful in case when we have a long number of classes, and a large number of objects being created and we have a certain conclusion and we want to verify it or for any obvious reason, we could use this thing. Here we create a different object for different classes.
A for anyone am poor middle class and here we have an object for this main class the cat t equals to a new cat see his object after cat class. And when I say we have used different methods or different things here in the program, and we did computer which method is forward which belongs to report class you can check here when we create a system or print ln m instance of animal it will check whether an instance of animal or not and we can also verify for different things instance of not whether or not I can see an instance of cat. So, if my thought were true we can write another string system out print ln see instance of cat our annual everything tape. So, let us execute this code and see what is being appearing on the screen showing true true true. So every time instance of animal because M is opted for Madeline and Emily's a childless of anyone.
So, m can access anyone see is an instance of man I can see is an object for cat and cat is a child class of mammal. So it is true and also false support animal because it follows multi level inheritance So we can verify that thing. If inheritance was not there, it could not be identified as well.