00:04
We are here to see some concepts and techniques that we can use in java programming for a quiz program.
00:11
So what we want to use are like class variables, instance variables, inheritance, polymorphism, extra classes, this keyword and super keyword.
00:19
All that as an object oriented programming we see the seven things that are used.
00:25
We are seeing all of them right now.
00:26
So first of all we'll see the class variable.
00:30
Now we can also call it as a static variable and it's declared at the class level and are shared among all instances of the class.
00:40
So we can use it using a static keyword and let's see how we can use it in a program.
00:46
For example, supposedly you keep public class and name it as a quiz because you are doing quiz program, creating a class.
01:01
So this is our class variable.
01:06
Commenting helps you have your working and also the person who's reading it.
01:14
Now private static integer and we are just asking about the questions we are having in the quiz.
01:26
So let's see like that.
01:28
So this is how we can create one class variable like this.
01:33
Now the next is the instance variable.
01:36
Now it is declared within a class but outside any method.
01:41
That's what instance variable is for.
01:43
It is declared inside the class but outside any method.
01:47
Okay.
01:49
They belong to each instance of the classes and have their own separate values.
01:53
So let's see how we can use the quiz program with using instance variable.
01:59
Now again we'll create a class known as public.
02:05
Public class quiz.
02:12
Coming to it.
02:15
This is my instance variable now.
02:19
So i'll get it private strings for everything.
02:23
Private string and the quiz name again going with the private list of questions.
02:44
Okay.
02:50
Then again private list of strings as answers.
03:00
Users answers.
03:06
This is how we can do all this too.
03:12
Now let's clear the canvas and go with the third thing.
03:17
That is our inheritance.
03:33
Right.
03:33
Now as we all know what is inheritance.
03:37
It allows us to create a subclass that inherits the properties and behaviors of an existing superclass.
03:44
Okay.
03:44
So now we can use inheritance to create specialized types of quizzes such as multiple choice quizzes or fill in the blanks.
03:52
Which inherits common features and methods from basic quiz class.
03:57
Right.
03:57
So let's see how we can write it.
04:00
It's very simple.
04:02
You can use it as public class multi choice quiz.
04:16
And from where it exchanges it exchange from the quiz class.
04:27
Right.
04:28
Let's go further with the fourth one which is our polymorphism.
04:33
Very integral integral part of our object oriented programming.
04:44
Now what does polymorphism do.
04:46
It allows objects of different classes to be treated as objects of a common superclass.
04:51
Right.
04:52
So what it does it enable us to use a single inherited interface to represent multiple related classes.
05:02
So where we can be using it while handling different types of quizzes where we can use a common quiz interface.
05:14
Right.
05:15
So you can see how it is.
05:19
We talked about it in inheritance event.
05:24
So what i can do is i made a class known as public public interface and quiz.
05:45
Right.
05:46
Void.
05:47
Display.
05:56
Question.
06:03
Again.
06:04
And the void.
06:06
Check.
06:08
Answer.
06:16
This is our.
06:18
Now what we'll do we'll create one class for multiple choice which is public class multiple choice quiz.
06:42
And what to do it implements.
06:47
Right.
06:50
Which class.
06:52
Quiz class.
06:58
This is a first class.
06:59
Again we can have the polymorphism here like public class.
07:05
Fill ups for filling the blank.
07:13
And again it implements quiz.
07:25
This is how we can use polymorphism.
07:28
So here we saw inheritance which is quite very easy to extend quiz to any of the class like multiple choice questions and again to the choice questions.
07:39
But we saw polymorphism implements those two classes.
07:43
Right.
07:44
This is how we see the difference.
07:46
That's again clear canvas and move forward with the abstract class.
08:02
So let's see.
08:06
Fifth one is abstract class.
08:17
Now.
08:17
By the name itself you can see that it's not easy.
08:22
Ok.
08:22
So abstract classes cannot be initiated but can provide a common base for other classes.
08:28
Ok.
08:29
Now they contain what abstract methods obviously...