0% found this document useful (0 votes)
9 views26 pages

Java Conditional Statements MCQs 101-150

The document contains multiple-choice questions (MCQs) related to Java conditional statements, specifically focusing on the output of various Java programs based on the value of an integer variable 'a'. Each question presents a Java code snippet and provides four options for the output, with the correct answer being either 'A' (Positive) or 'B' (Non-Positive) depending on the value assigned to 'a'. The questions range from negative to positive integers, testing the understanding of conditional statements in Java.

Uploaded by

aksharadeepa796
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views26 pages

Java Conditional Statements MCQs 101-150

The document contains multiple-choice questions (MCQs) related to Java conditional statements, specifically focusing on the output of various Java programs based on the value of an integer variable 'a'. Each question presents a Java code snippet and provides four options for the output, with the correct answer being either 'A' (Positive) or 'B' (Non-Positive) depending on the value assigned to 'a'. The questions range from negative to positive integers, testing the understanding of conditional statements in Java.

Uploaded by

aksharadeepa796
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Java Conditional Statements – MCQs (101–150)

101. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -19;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

102. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -18;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

103. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -17;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

104. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -16;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

105. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -15;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

106. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -14;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

107. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -13;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

108. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -12;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

109. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -11;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

110. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -10;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

111. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -9;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

112. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -8;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

113. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -7;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

114. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -6;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

115. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -5;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

116. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -4;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

117. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -3;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

118. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -2;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

119. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = -1;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

120. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 0;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

121. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 1;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

122. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 2;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

123. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 3;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

124. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 4;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

125. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 5;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

126. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 6;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

127. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 7;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

128. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 8;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

129. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 9;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

130. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 10;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

131. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 11;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

132. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 12;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

133. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 13;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

134. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 14;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

135. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 15;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

136. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 16;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

137. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 17;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

138. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 18;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

139. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 19;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

140. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 20;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

141. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 21;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

142. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 22;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

143. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 23;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

144. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 24;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

145. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 25;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

146. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 26;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

147. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 27;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

148. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 28;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

149. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 29;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output

Correct Answer: A or B (based on value)

150. What will be the output of the following Java program?

public class Example {


public static void main(String[] args) {
int a = 30;
if (a > 0)
[Link]("Positive");
else
[Link]("Non-Positive");
}
}

Options:
A. Positive
B. Non-Positive
C. Compilation error
D. No output
Correct Answer: A or B (based on value)

You might also like