bublic ne tollowing program: class Conditionals public static void main (Stringt
ID: 3728540 • Letter: B
Question
bublic ne tollowing program: class Conditionals public static void main (Stringt args) 7Read a string from command line and // convert to int nt N Integer.parseint (args toj)a String s-"a" String t if (N -10 &&N20;) else if (N -25) else if (N30) else s=s+t; s-t+8: S-s+S s=t+t; S S+S if (N % 3-= 0) { if (N % 5 !=0) t-t+ s: system.out.printin(st) Answer the following two sub-questions: i. Give the result of executing this program with following command: % java conditionals 15 li. Which (one or more) of the following correspond to the output of Conditionals for some positive input value of N? Circle all correct answers. ababbab abb
Explanation / Answer
Initital value of s = "a", t = "b"
Since N=15, it will evaluate first IF condition as true
s= s + t = "ab"
Now it will also evaluates true for las IF: if(N%3 = 0)
t = s + t => "ab" + "b" => "abb"
Output: s + t => "ab" + "abb" => ababb
Ans: abb, bbb,
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.