Java program to reverse vowels of a string


Program : Java example program to Reverse Vowels  in a String



  1. package inheritanceInterviewPrograms;
  2. /*
  3.  * @www.instanceofjava.com
  4.  */
  5. public class ReverseVowels {
  6.     public static String reverseVowels(String string) {
  7.  
  8.         String vowelsStr = "aeiouAEIOU";
  9.  
  10.         int lo = 0;
  11.         int hi = string.length() - 1;
  12.         char[] ch = string.toCharArray();
  13.  
  14.  while (lo < hi) {
  15.  
  16.      if (!vowelsStr.contains(String.valueOf(string.charAt(lo)))) {
  17.                 lo++;
  18.                 continue;
  19.        }
  20.  
  21.     if (!vowelsStr.contains(String.valueOf(string.charAt(hi)))) {
  22.                 hi--;
  23.                 continue;
  24.        }
  25.  
  26.     // swaping variables
  27.      swap(ch, lo, hi);
  28.             lo++;
  29.             hi--;
  30.       }
  31.  
  32.         return String.valueOf(ch);
  33.     }
  34.  
  35. private static void swap(char[] ch, int lo, int hi) {
  36.  
  37.         char temparray = ch[lo];
  38.         ch[lo] = ch[hi];
  39.         ch[hi] = temparray;
  40.  
  41.  }
  42.     
  43. public static void main (String args[]) {
  44.         
  45.          
  46.  System.out.println("After reversing vowels in a string="reverseVowels("InstanceOfjava"));
  47.         
  48.          
  49. }
  50.  
  51. }
Output:


  1. After reversing vowels in a string=anstancOefjavI


Core java online programming test on inheritance

  • Inheritance means getting properties from one class object to another.
  • So in sub class we can use or access super class variables and method : re usability
  • There are some interesting and important points to discuss about inheritance
  • In major java interviews and java online test on core java there is more chance of getting programming questions from inheritance
  • So let us see some java test questions. java test online to practice
  • If you want explanations then visit below topic
  • Top 16 Java Inheritance Interview questions for freshers and experienced  




5 Points to know about inheritance:

Program #1: Java test on inheritance:
  • Creating object for super class and calling super class methods and accessing super class variables.

  1. package interviewprograms.instanceofjava;
  2. public class Super{
  3.  
  4.  int a, int b;
  5.  
  6. void show(){
  7.  System.out,println("Inside Show method");
  8. }
  9.  
  10. }



  1. package interviewprograms.instanceofjava;
  2. public class Sub extends Super{
  3.  int a, int b;
  4. public static void main(String[] args) {
  5.         
  6. Super obj= new Super();
  7. obj.a=10;
  8. System.out,println(obj.a);
  9.  obj.show();
  10. }
  11. }






Program #2: Core Java online test on inheritance:
  • Creating object for sub class and calling sub class methods and accessing sub class variables.

  1. package interviewprograms.instanceofjava;
  2. public class Super{
  3.  
  4.  int a, int b;
  5.  
  6. void show(){
  7.  System.out,println("Inside Show method");
  8. }
  9.  
  10. }

  1. package interviewprograms.instanceofjava;
  2.  
  3. public class Sub extends Super{
  4.  int x;
  5.  
  6.  
  7. void show(){
  8.  System.out,println("Inside Sub class Show method");
  9. }
  10. public static void main(String[] args) {
  11.         
  12. Sub obj= new Sub ();
  13. obj.x=10;
  14. System.out,println(obj.x);
  15.  obj.show();
  16. }
  17. }





Program #3: core java online test for beginners and experienced on inheritance
  • Creating object for sub class accessing super class members and sub class members.

  1. package interviewprograms.instanceofjava;
  2. public class Super{
  3.  
  4.  int a, int b;
  5.  
  6. void show(){
  7.  System.out,println("Inside Show method");
  8. }
  9.  
  10. void print(){
  11.  System.out,println("Inside super class print method");
  12. }
  13.  
  14. }

  1. package interviewprograms.instanceofjava;
  2.  
  3. public class Sub extends Super{
  4.  int x;
  5.  
  6.  
  7. void show(){
  8.  System.out,println("Inside Sub class Show method");
  9. }
  10. void msg(){
  11.  System.out,println("Inside Sub class msg method");
  12. }
  13. public static void main(String[] args) {
  14.         
  15. Sub obj= new Sub ();
  16. obj.x=10;
  17. System.out,println(obj.x);
  18.  obj.show();
  19. obj.print();
  20. }
  21. }







Program #4: core java online test for beginners and experienced on inheritance
  • Creating object for sub class and assigning to super class reference.

  1. package interviewprograms.instanceofjava;
  2. public class Super{
  3.  
  4.  int a, int b;
  5.  
  6. void show(){
  7.  System.out,println("Inside Show method");
  8. }
  9.  
  10. void print(){
  11.  System.out,println("Inside super class print method");
  12. }
  13.  
  14. }


core java online test for beginners






Program #5: core java online test for beginners and experienced on inheritance

  • Creating object for sub class and assigning to super class reference and calling sub class method.
  1. package interviewprograms.instanceofjava;
  2. public class Super{
  3.  
  4.  int a, int b;
  5.  
  6. void show(){
  7.  System.out,println("Inside Show method");
  8. }
  9.  
  10. void print(){
  11.  System.out,println("Inside super class print method");
  12. }
  13.  
  14. }


  1. package interviewprograms.instanceofjava;
  2.  
  3. public class Sub extends Super{
  4.  int x;
  5.  
  6.  
  7. void show(){
  8.  System.out,println("Inside Sub class Show method");
  9. }
  10.  
  11. void msg(){
  12.  System.out,println("Inside Sub class msg method");
  13.  
  14. public static void main(String[] args) {
  15.         
  16. Super obj= new Sub (); 
  17. obj.msg();
  18. }
  19. }





EnJoY LeArNinG  WitH Us...

Java interview questions to practice

  • We have provided some java interview programming questions for freshers and experienced candidates.
  • So please try to answer these java interview questions and practice.
  • If you have any doubt go through the given explanation link you can get the answer for that.
  • Still if  you need any clarifications feel free to contact us. Skype/Gmail: instanceofjava




Program #1: what will happen if we try to interchange modifiers of main method

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





Program #2:Do you know about static in java . How static works?


java interview questions for experienced candidates





Program #3:Java Interview question on try catch block in java

  1. package interviewprograms.instanceofjava;
  2. public class InterviewProgram {
  3.  
  4. /**
  5. * @java interview programming  questions and answers for freshers and experienced
  6.  */
  7.   
  8. public static void main(String[] args) {
  9.         
  10.  try {
  11.  
  12.             System.out.println("I am try block");
  13.             
  14. } finally {
  15.  
  16.             System.out.println("I am finally block");        }
  17.  
  18. }
  19. }







Program #4:Java Interview question on what happens when we print object
  1. package interviewprograms.instanceofjava;
  2. public class InterviewProgram {
  3.  
  4. /**
  5. * @java interview programming  questions and answers for freshers and experienced
  6.  */
  7.   
  8. public static void main(String[] args) {
  9.         
  10.  try {
  11.  
  12.             System.out.println("I am try block");
  13.             
  14. } finally {
  15.  
  16.             System.out.println("I am finally block");        }
  17.  
  18. }
  19. }





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
Select Menu