Java Interview Questions | Control Statements | Fresher Interview | Java Tutorial | Code Bode

Pubblicato il: 05 giugno 2020
sul canale di: CodeBode
2,516
70

#javainterviewquestionsandanswers #javatutotial #controlstatements

Hi Guyz,

This video covers most commonly asked interview questions and answers on if, for, switch, for loop, while loop,do-while loop, continue

Q.1) What are the three loops in Java?
Ans. For llop,while loop and dowhileloop

Q.2) Difference between while loop & do while loop?
Ans. In while loop condition is checked first . Only if the condition is true loop is executed.
In do while loop first loop is executed and then condition is checked. So loop executes atleast once.

Q.3) Real time example where do while can be used?
Ans . Program to take input until user enters 0.
int number=0;
Scanner sc = new Scanner(System.in);
do {
system.out.println(“Enter a number”);
number = sc.nextInt();
}while(number!=0)

Q.4) Difference between break & continue?
Ans. Break terminates the loop. Continue exits the current iteration

Q.5) what happens if we write switch without break?
Ans. we write switch without break all conditions are executed even if condition is matched in one of the case

Q.6) When to use switch statement over if?
Ans. When the condition is to be checked against list of values switch should be used. For checking boolean conditions if statement can be used.
e.g, displaying month or week from number

Q.7) Can we have two identical cases inside switch
Ans. No. Switch allows unique cases only

Q.8) What will be the output of?
for(;;) {
System.out.println(“1”);
}

Ans.Infinite loop

Q.9) what are nested for loop?
Ans. Loop inside loop is a nested for loop

Q.10) Can we have nested switch?
Ans. Yes

#arraysinjava #javatutorial #reversearray

Hi Guyz,
In This Video We will learn how to reverse an array in java.
Algorithm -
1) Take a predefined array or take a user input array
2) Print the array as it is
3) Iterate a loop from arrayLength-1 up to 0 and in each iteration decrement the index
4)Print value of array inside the loop


Watch the video for understanding the code step by step.

Other Playlist :

Eclipse Tutorial :
   • Eclipse Tutorial  
HTML Tutorial :
   • Playlist  
Java Learning Path :


HAPPY LEARNING!


In questa pagina del sito puoi guardare il video online Java Interview Questions | Control Statements | Fresher Interview | Java Tutorial | Code Bode della durata di ore minuti seconda in buona qualità , che l'utente ha caricato CodeBode 05 giugno 2020, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 2,516 volte e gli è piaciuto 70 spettatori. Buona visione!