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

Veröffentlicht am: 05 Juni 2020
auf dem Kanal: 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!


Auf dieser Seite können Sie das Online-Video Java Interview Questions | Control Statements | Fresher Interview | Java Tutorial | Code Bode mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer CodeBode 05 Juni 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 2,516 Mal angesehen und es wurde von 70 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!