in Technology by

Which of the following for loop declaration is not valid?

a) for ( int i = 99; i >= 0; i / 9 )

b) for ( int i = 7; i <= 77; i += 7 )

c) for ( int i = 20; i >= 2; - -i )

d) for ( int i = 2; i <= 20; i = 2* i )

🔗Reference: stackoverflow.com

🔗Source: Java Interview Questions and Answers

1 Answer

0 votes
by

Answer: (a) for ( int i = 99; i>=0; i / 9)

Explanation: The first option is not a valid declaration as i/9 is not declared correctly. The correct statement will be:
      for ( int i= 99; i>=0; i= i/9)

Then the code would execute. But without assigning the value of i/9 to a variable, it would not execute, and an exception is thrown, as shown below.

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
      Syntax error on token "/", invalid AssignmentOperator

The other three statements are valid and will execute. Hence, the correct answer is the option (a).

Related questions

0 votes
    Which of the following is a valid declaration of a char? a) char ch = '\utea'; b) char ca ... ;Reference: stackoverflow.com 🔗Source: Java Interview Questions and Answers...
asked Dec 19, 2020 in Technology by Editorial Staff
0 votes
    Which of the following is a valid declaration of an object of class Box? (a) Box obj = new Box( ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    Which is a valid declaration within an interface? A)protected short stop = 23; b)final void madness(short stop); ... (double duty);? Select the correct answer from above options...
asked Dec 1, 2021 in Education by JackTerrance
0 votes
    Which of the following is not a valid encoding scheme for character?a. ASCII b. ISCII c. Unicode and. ASCII Select the correct answer from above options...
asked Dec 25, 2021 in Education by JackTerrance
0 votes
    which of the following points are not valid for ram (a) primary memory (b) main memory (c) second memory Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    Each array declaration need not give, implicitly or explicitly, the information about (a) The name of ... Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    Which of the following is not a valid Hadoop config file? 1. core-default.xml 2. hdfs-default.xml 3. hadoop-default.xml 4. mapred-default.xml...
asked Apr 13, 2021 in Technology by JackTerrance
+1 vote
    Which of the following are not valid in JavaScript? a) "My name is "Harry" " b) "My name is Harry" c)"My name is Harry' d) "My name is 'Harry' "...
asked Oct 8, 2020 in Technology by JackTerrance
0 votes
    Which of the following is not a valid scanning method? (a) Xmas Tree scan (b) SYN Stealth scan (c) ... ?,Need-for-Cyber Security:,Cyber Security-Jobs:,Cyber Security Applications...
asked Nov 1, 2021 in Education by JackTerrance
0 votes
    Which of the following term is not a valid terminology and type of adware? (a) Mobile adware (b) Mac ... ,Need-for-Cyber Security:,Cyber Security-Jobs:,Cyber Security Applications...
asked Oct 31, 2021 in Education by JackTerrance
0 votes
    Which of the following is not a valid jump statement? (a) break (b) goto (c) continue (d) ... java programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    Which of the following are not valid in JavaScript? 1. "My name is "Harry" " 2. "My name is Harry" 3. My name is Harry' 4. "My name is 'Harry' "...
asked Feb 23, 2021 by JackTerrance
0 votes
    Which of the following is used to terminate the function declaration in C++? a) ; b) ] c) ) d) :...
asked Oct 19, 2022 in Education by JackTerrance
0 votes
    which of the following java declaration of the string Array is correct? Select the correct answer from above options...
asked Dec 29, 2021 in Education by JackTerrance
0 votes
    Which of the following is not a phase in hunting loop? A. Inform and enrich analytics B. Uncover new patterns and TTP’s C. Creating hypothesis D. Innovative approach...
asked Feb 27, 2023 in Technology by JackTerrance
...