Java programming interview questions and answers for experienced

  • Here some of the java programming interview questions and answers for experienced on different topics.
  • Java interview programs and answers for experienced.
  • Java Coding interview Questions
  • Java tricky interview programs to practice.




 Program #1: what will happen if we try to print null using system.out.println

  1. package interviewprograms.instanceofjava;
  2. public class InterviewProgram {
  3.  
  4.     /**
  5.      * @java programming interview questions and answers for freshers and experienced
  6.      */
  7.     public static void main(String[] args) {
  8.         
  9.         System.out.println(null);
  10.  
  11.     }
  12.  
  13. }






Program #2: Java Interview program :Can we create object for abstract class in same class

  1. package interviewprograms.instanceofjava;
  2. public abstract class AbstractDemo {
  3.  
  4. public static void main(String args[]){
  5.         
  6.         AbstractDemo obj = new AbstractDemo();
  7.         
  8.  }
  9.  
  10. }





Program #3: Java Interview program : what will be the output of below java program


Java programming interview questions and answers for experienced





 Program #4: Guess the order of execution of constructors

  1. package interviewprograms.instanceofjava;
  2. public class ConstructorDemo {
  3.  
  4. ConstructorDemo(){
  5.         this(1);
  6.         System.out.println("Zero argument constructor");
  7. }
  8.     
  9. ConstructorDemo(int a){
  10.         this("Hi",1);
  11.         System.out.println("One argument constructor");
  12. }
  13.  
  14. ConstructorDemo(String str, int x){
  15.     
  16.         System.out.println("Two argument constructor");
  17. }
  18.  
  19. public static void main(String[] args) {
  20.  
  21.         ConstructorDemo obj =new ConstructorDemo();
  22.  
  23.     }
  24.  
  25. }





Super keyword java programs for interview for freshers and experienced

  • 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

  1. package com.superkeywordinjava;
  2.  public Class SuperDemo{ 
  3.  
  4. int a,b;
  5.  
  6. }

  1. package com.superkeywordinjava;
  2. public Class Subdemo extends SuperDemo{ 
  3. int a,b;
  4. void disply(){

  5. super.a=10;
  6. super.b=20;
  7.  
  8. System.out.println(a);
  9. System.out.println(b);
  10. System.out.println(super.a);
  11. System.out.println(super.b);
  12.  
  13. }
  14.  
  15. public static void main (String args[]) {
  16.  Subdemo obj= new Subdemo();
  17.  
  18. obj.a=1;
  19. obj.b=2;
  20.  
  21. obj.disply();
  22.  

  23.  
  24. }
  25. }






Program #2: What will be the output of below java program


super keyword java interview programs for freshers





Program #3: Basic java programs for interview on super keyword

  1. package com.superinterviewprograms;
  2. public Class SuperDemo{ 
  3.  
  4. int a,b;
  5.  
  6. SuperDemo(int x, int y){
  7.  a=x;
  8. b=y
  9. System.out.println("Super class constructor called ");
  10.  
  11.  
  12. }

  1. package com.superinterviewprograms;
  2.  
  3. public Class Subdemo extends SuperDemo{ 
  4.  
  5. int a,b;
  6.  
  7. SubDemo(int x, int y){
  8. super(10,20);
  9.  a=x;
  10. b=y
  11. System.out.println("Sub class constructor called ");
  12. }
  13.  
  14. public static void main (String args[]) {
  15.  Subdemo obj= new Subdemo(1,2);

  16.  
  17. }
  18. }





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.

  1. package com.superinterviewprograms;
  2.  
  3. public Class Sample{ 
  4.  
  5. Sample(){
  6. super();
  7. System.out.println("Sample class constructor called "); 
  8.  
  9. }
  10.  
  11. public static void main (String args[]) {
  12.  
  13.  Sample obj= new Sample();
  14.  
  15. }
  16. }





How to watch online movies with subtitles in english for free without downloading

  • 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.


watch movies with english subtitles online streaming



 Step #2: download the .srt file of the movie 

  • After adding firefox extension download .srt file of the movie
  • And open with notepad and copy.
Step #3: open online video and right and add subtitles

  • Now right click on the movie and select paste subtitles from clipboard. 
  • Enjoy watching online movies with English, french .... subtitles
  • Watch English movies online for free without downloading
  • Watch Hollywood movies with subtitles watch Hindi movies with English subtitles.
  • watch Hollywood horror movies online free without downloading with subtitles 
  • watch korean movies with english subtitles
watch hollywood movies with english subtitles online

Private constructor in java example


Constructor in java:

  • Constructor is used to initialize class variables.
  • Constructor will be executed once per object and whenever object is created constructor will be called.




Private Constructor in java:

  • We can make constructor private, public , protected and default.
  • If we define a constructor as private means we are restricting a class to create object  outside of the class.
  • A class having private constructor does not allow user to create object outside.
  • In singleton Design pattern we will use private constructor to restrict object creation


  1. package inheritanceInterviewPrograms;
  2.  
  3. public class A {
  4.   
  5.   private A(){
  6.        
  7.        
  8.    }
  9.  
  10. public static void main(String args[]){ 
  11.    
  12.       A s= new A();
  13.   }
  14.  
  15. }

  1. package inheritanceInterviewPrograms;
  2. //  www.instanceofjava.com
  3.  
  4. public class B {
  5.     
  6. public static void main(String [] args){
  7.      
  8.     A obj= new A();// Compile time error
  9.    
  10.  
  11. }
  12. }


private Constructor example

Super keyword in java inheritance example

  • By using super keyword we can access super class variables and super class methods in sub class.
  • "Super" always refers to super class object.
  • One more interesting point about super is we can call super call constructors from sub class constructor using super keyword.
  • By default in sub class constructor super() call will be added by jvm.
  • We can also explicitly mention super call but rule is super() call must be first statement of the sub class constructor.
  • Let us see how sub class constructor calls super class constructors automatically. 


Java example program to demonstrate super call execution from sub class constructor to super class constructor 


  1. package com.superkeywordinjava;
  2.  public Class SuperDemo{ 
  3.  
  4. SuperDemo(){
  5. System.out.println("Inside super class constructor");
  6. }
  7.  
  8. }

  1. package com.superkeywordinjava;
  2. public Class Subdemo extends SuperDemo{ 
  3.  
  4. Subdemo(){
  5. System.out.println("Inside sub class constructor");
  6. }
  7.  
  8. public static void main (String args[]) {
  9.  Subdemo obj= new Subdemo();
  10.  
  11.  
  12. }
  13. }

Output:

  1. Inside super class constructor
  2. Inside sub class constructor


  • In the above programs whenever we are creating object of the sub class corresponding sub class constructor will be executed 
  • By default in sub class constructor super(); call will be added so now it will call super class zero argument constructor.

  1. Subdemo(){
  2. super(); // will be added automatically
  3. System.out.println("Inside sub class constructor");
  4. }

  • Whenever there is no constructor in sub class then default constructor added automatically and that contains super call in it.
  • And also when ever we define a constructor in our class .By default super(); call will be added automatically as first statement.
Java example program to demonstrate super call execution from sub class constructor to super class constructor by placing super call explicitly.


  1. package com.superkeywordinjava;
  2.  public Class SuperDemo{ 
  3.  
  4. SuperDemo(){
  5. System.out.println("Inside super class constructor");
  6. }
  7.  
  8. }

  1. package com.superkeywordinjava;
  2. public Class Subdemo extends SuperDemo{ 
  3.  
  4. Subdemo(){
  5. super();
  6. System.out.println("Inside sub class constructor");
  7. }
  8.  
  9. public static void main (String args[]) {
  10.  Subdemo obj= new Subdemo();
  11.  
  12.  
  13. }
  14. }

Output:

  1. Inside super class constructor
  2. Inside sub class constructor

  • Super call must be first statement inside the sub class constructor otherwise compile time error will come.
super keyword in java inheritance


  • If super class having parameterized constructor it is mandatory to call super class constructor explicitly by passing required parameters.
  • other wise compile time error will come

super in inheritance in java



  1. Sub(){
  2. super(1,2); // will work fine
  3. System.out.println("Inside sub class constructor");
  4. }

Java programming interview questions on this keyword part 3



Java Quiz on this keyword part #3

Program #9: Is it possible to Pass this as parameter of a method?

  1. package thiskeywordinterviewprograms.java;
  2.  
  3. public class ThisDemo {
  4.     int a,b;
  5.     
  6. public ThisDemo Show(){
  7.         
  8.   this.a=10;
  9.   this.b=20;
  10.   return this;
  11. }
  12.  
  13. public static void main(String[] args) {
  14.         
  15.     ThisDemo obj = new ThisDemo();
  16.         
  17.   System.out.println("a="+obj.a);
  18.   System.out.println("b="+obj.b);
  19.   ThisDemo obj1 = obj.Show();
  20.         
  21.   System.out.println("a="+obj1.a);
  22.   System.out.println("b="+obj1.b);
  23.         
  24. }
  25.  
  26. }






Program #10: Is is possible to access static variables and static methods using this keyword?

java programming this keyword





Program #11:Java program to test whether we can use this in static block or not?


  1. package thiskeywordinterviewprograms.java;
  2. public class ThisDemo {
  3.  
  4.   static int a,b;
  5.     
  6. static{
  7.     
  8.     this.a=10;
  9.     this.b=20;
  10. }
  11.  
  12. public static void main(String[] args) {
  13.         
  14.   ThisDemo obj = new ThisDemo();
  15.         
  16.   System.out.println("a="+obj.a);
  17.   System.out.println("b="+obj.b);
  18.       
  19.   
  20. }
  21.  
  22. }





Program #12: Java interview program to test whether we can use this in static methods?


  1. package thiskeywordinterviewprograms.java;
  2. public class ThisDemo {
  3.  
  4.     static int a,b;
  5.    
  6.  
  7. public static void main(String[] args) {
  8.  

  9.   ThisDemo obj = new ThisDemo();
  10.    this.a=10;
  11.    this.b=20;    
  12.   System.out.println("a="+obj.a);
  13.   System.out.println("b="+obj.b);
  14.       
  15.     
  16. }
  17.  
  18. }







Select Menu