Discussion :: Flow Control - General Questions (Q.No.4)
Sundar said: (Sep 17, 2011) | |
I got the following error while compiling the above code. -------------------------------------------------------------- While.java:6: incompatible types found : int required: boolean while ( 1 ) /* Line 6 */ ^ 1 error. -------------------------------------------------------------- Therefore, the given answer is correct. |
M.Siddhartha said: (Jul 18, 2012) | |
while is a keyword in JAVA and we can't assign a keyword to a class and give a satisfactory explanation for it. |
Arjun said: (Aug 11, 2013) | |
While will take boolean value like if? |
Sanket said: (Oct 6, 2013) | |
no, 'while' will take boolean values! Syntax: while(condition) { //block of statements } |
Arun said: (Oct 14, 2013) | |
Answer is D. Because while loop accepts boolean but not Integer as an expression. So the error will be in line no.6 only. Remaining code is perfect. |
Anjaneyulu said: (Nov 17, 2013) | |
According to java naming rules keywords are not used for class name but in this Example your used while, in java while is a key word, but your not given the that error by. |
Kalyan said: (Jan 28, 2014) | |
Here class name is 'While' and starts with caps 'W' not with 'w'. So we can use While as class name. We should not use while keyword as class name. Because keywords start with small letters and they are reserved in java. We have used caps 'W' in the given program so it is not matched with java keyword i.e. while. |
Dnyaneshwar Shivbhakta said: (Feb 3, 2014) | |
While is keyword in java and keywords are not allowed for User Defined Class. |
Vinod Wakdde said: (Feb 22, 2014) | |
Explain correct syntax of "while"? |
Santosh said: (Jun 20, 2014) | |
1. While is a key word, here all letters are small letter. 2. While, it is not a key word because it starts with Capital letter. That's why java is a case sensitive programming language. |
Naveen Pandey said: (Dec 5, 2014) | |
To being a keyword the word must be start with capital letter. So, the use of While for class name is correct. |
Naveen Pandey said: (Dec 5, 2014) | |
To being a keyword the word must be in small letter. So the use of While will not be use as a keyword. |
Chandan Kumar Barnwal said: (Sep 23, 2017) | |
Simple, while loop can have the only condition that will be true or false, 1 means true 0 means false, it accepts in C /C++, not in java Java accept only true/false values as a condition. |
Nazir Khan said: (Jul 23, 2019) | |
Because java is case sensitive language that's why there is no error in line 1. |
Post your comments here:
Name *:
Email : (optional)
» Your comments will be displayed only after manual approval.