QUESTION 35 Anal e the following code Enter an integer Scanner input new Scanner(System in int number input nextInt0; if (number
Expert Answer
Question 35:
package venkanna; import java.util.Scanner; public class Sampledata { public static void main(String[] args) { Scanner input = new Scanner(System.in); int number = input.nextInt(); if (number <= 0) System.out.println(number); } } Answer: 3.If number is Zero,number is displayed. Explanation: Why because.In the Condition number<=0. means if given input less or equal to 0.Then block will execute. Let statement 1:It is just Simple if Statement No need to write else Block. Hence it is Wrong Let statement 2:If Statement Contains Single Block of Statement, Then No need to Place inside The Curly Braces. Incase If contains Group of statements(more than one) Then we have to place inside Braces. Let statement 4:number<=0. it is Satisfied only for 0 or Negative values. Let statement 5:If Condition Accepts Both zero and negative values so this is also wrong. Question 19: Which of the Following Operators have the Highest Precedence? 1.Casting 2.+ 3.* 4./ Answer:Casting Question 31: The Conditional Operator ?:is a _______ Answer:3.Ternary Operator