Hi, welcome back. Here in this practical exercise, we will be learning multiple keywords and terms. We will be using this super keyword and pass values with object and would associate between two different entities. So let's start with this program. Let us first write a class, declare the class then how declined we could have different methods or arguments with this class that we missed right here. This super keyword says thanks for the record.
We have a car class having a variable called car name called a string. Car ID Typing, we have the constructor car with the same name as the class. It has two different variables, name and ID. It is a parameterised constructor having two different parameters or variables, name and ID here, we could have access, we could pass the value from the constructor to the variable class variables using this keyword. This dot car name is the car name variable of the class car. However, a name is an instance, or the value that has been passed to the constructor.
So you can assign this. This is the user of this keyword. Similarly, we have another class driver that extends from this car class or in his car. Bad we have a screen called right with me. We have a contract vector which is also parameterised constructor for the driver class having two different arguments, name teaming and the third argument FC ID. We would also create multiple constructors for the same class, each having a different number of variables.
And that could be zero number of variables, more and more to four and anything with different return types. Here we also use another keyword that is super because access the super method using other super for the superclass, a senior NC ID we pass the car name and car ID to the super method, an accessor driver name or pass the other this create the main class create a main method public static void Main String args then create an object for the class. It's simply that in the class name, their driver object OBJ object this object OBJ object, driver class. And let us pass or differentiate of values directly from this class name, it will we initiate it to the constructor, the value to pass to the constructor. The driver constructor has three arguments. First is type of integer, second is integer, and third is a sort of first is a string, second is a string and third is integer.
So the first two are a strange name and car name. The person's name and a car name, BMW, then we have the car ID to two rate is being passed, when we call the system or printer and method it will display the name of the trailer by using the driver name from the object you could access that thing directly and the driver name is thing called similarly we could access the car ID directly from here we have to make this main class public and then we can execute this thing. Without it has not identified we have to place some And then I think seven columns which are when we have the same type of return type, it will do this thing I guess me. So that is the trailer of the car ID 2248 it is being displayed. Here we have the user super constructor also for method, this keyword to access the current variable of the class, the class variable and we can use the object of the child to access the parent.
One solution I use these keywords and this super amore when you have the inheritance or object oriented programming approach