Tik Tik

Observe the following coding in Java and find how many times will "Tik Tik" printed??

for(int i=150; i<151;i=300-i);System.out.println("Tik Tok");
# Log on to comprogzz.in for more such java programming
0 times 300 times infinite times 1 times

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

5 solutions

Rama Devi
May 27, 2015

The code has Tik Tok and not Tik Tik.Therefore the answer is 0.

I didn't give so much time to think :) hahah I've notice it's tik tok not ti tik :D

Sonali Srivastava
Jul 21, 2014

Since there is a semicolon at the end of the for loop hence the next printing statement will execute only after it finishes its execution. But as value of i is updated to 150 always which fulfills the condition i<151 hence the loop executes infinitely n next statement doesn't execute even once.

Mayank Holmes
Jun 14, 2014

if we give a semicolon after the FOR loop, it won't work even once!! hence, no output!!

the command is "tik tok" not "tik tik"

Samarth Badyal - 6 years, 11 months ago

yes! that's true but my statement is also correct!

Mayank Holmes - 6 years, 11 months ago

The command is for "Tik Tok" not "Tik Tik"

nothing would be printed! see the semicolon just after the for loop , it terminates the loop before it starts working!

Mayank Holmes - 6 years, 12 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...