#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!
On this page of the site you can watch the video online Java Interview Questions | Control Statements | Fresher Interview | Java Tutorial | Code Bode with a duration of hours minute second in good quality, which was uploaded by the user CodeBode 05 June 2020, share the link with friends and acquaintances, this video has already been watched 2,516 times on youtube and it was liked by 70 viewers. Enjoy your viewing!