Lets see some interesting java programs on super keyword.
Basically super keyword used to refer super class methods and variables. So now let us see how super will work in some scenarios. lets practice.
Try to answer below java programming interview questions for beginners.
Java programs asked in technical interview for freshers and experienced.
Program #1: What will be the output of below java program
package com.superkeywordinjava;
public Class SuperDemo{
int a,b;
}
package com.superkeywordinjava;
public Class Subdemo extends SuperDemo{
int a,b;
void disply(){
super.a=10;
super.b=20;
System.out.println(a);
System.out.println(b);
System.out.println(super.a);
System.out.println(super.b);
}
public static void main (String args[]) {
Subdemo obj= new Subdemo();
obj.a=1;
obj.b=2;
obj.disply();
}
}
1
2
10
20
Program #2: What will be the output of below java program
1
2
10
20
Program #3: Basic java programs for interview on super keyword
package com.superinterviewprograms;
public Class SuperDemo{
int a,b;
SuperDemo(int x, int y){
a=x;
b=y
System.out.println("Super class constructor called ");
}
}
package com.superinterviewprograms;
public Class Subdemo extends SuperDemo{
int a,b;
SubDemo(int x, int y){
super(10,20);
a=x;
b=y
System.out.println("Sub class constructor called ");
}
public static void main (String args[]) {
Subdemo obj= new Subdemo(1,2);
}
}
Super class constructor called
Sub class constructor called
Program #4: Java interview Program on super keyword
What will happen if our class constructor having super() call but our class not extending any class.
package com.superinterviewprograms;
public Class Sample{
Sample(){
super();
System.out.println("Sample class constructor called ");
}
public static void main (String args[]) {
Sample obj= new Sample();
}
}
Sample class constructor called
if our class not extending any class Yes still we can use super(); call in our class
Because in java every class will extend Object class by default this will be added by JVM.
But make sure we are using only super(); default call we can not place parameterized super call because Object class does not have any parameterized constructor.
Now we are going to see how to play online streaming videos with English subtitles or your language subtitles.
Whenever we want to see some movie we will search it on search engine like google and will choose one site then will play the movie but we wont find sub titles for it then we will shift to another site for online streaming.
Then we will download the movie and add the subtitles to the player.
So instead of downloading and adding. we need to add subtitles online itself.
Now we will see how to add subtitles to online streaming movie
Now watch movies with English subtitles.
How to add subtitles to online streaming movie:
We need to add add on to our browser . if you are using Firefox:
Then add : Online subtitles 1.0.1 to your Firefox.
Provide an easy way of adding subtitles to online videos.With this addon users can add subtitles to online videos. In this way downloading the video for subtitling is avoided. To add subtitles: 1. You must first copy the contents of the .srt file to the clipboard. 2. Right click a video. 3. Click on the menu: Paste subtitles from clipboard.
Step #1: add Online subtitles 1.0.1 to your Firefox.
There are lot of useful ad-dons available we have selected one.