Computer Applications
What will be the output of the following program segment?
int a = 100;
while(false)
{
if(a < 50)
break;
a = a - 10;
}
System.out.println(a);
Java Iterative Stmts
11 Likes
Answer
Output
100
Explanation
Since the condition of while loop is false, the body of while loop will not execute. The print statement following the loop will execute and print 100 on the screen.
Answered By
7 Likes
Related Questions
Evaluate the following expressions, when int a = 8, b = 14.
(a) b/a++
(b) --a + b-- + a
Write the syntax of switch statement.
Define a class with the following specifications
Class name : employee
Member variables
eno : employee number
ename : name of the employee
age : age of the employee
basic : basic salary (Declare the variables using appropriate data types)Member methods
void accept( ) : accept the details using scanner class
void calculate( ) : to calculate the net salary as per the given specificationsnet = basic + hra + da - pf
hra = 18.5% of basic
da = 17.45% of basic
pf = 8.10% of basicif the age of the employee is above 50 he/she gets an additional allowance of ₹5000
void print( ) : to print the details as per the following format
eno ename age basic net
void main( ) : to create an object of the class and invoke the methods
Define a class to accept the elements of an array from the user and check for the occurrence of positive number, negative number and zero.
Example
Input Array: 12, -89, -56, 0, 45, 56
Output:
3 Positive Numbers
2 Negative Numbers
1 Zero