Welcome to Dream.In.Code
Become a Java Expert!

Join 149,497 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,371 people online right now. Registration is fast and FREE... Join Now!




Boolean ?'s and others

 
Reply to this topicStart new topic

Boolean ?'s and others, help

elielobt
18 Mar, 2007 - 09:46 PM
Post #1

New D.I.C Head
*

Joined: 2 Feb, 2007
Posts: 8


My Contributions
i want to check if this expression is true if the number x is between 1 and 100 or the # is negative...

Here are the errors:
not a statement
boolean = ((x<100) &&(x>1)) ||(x<0);
^
numOne.java:7: ';' expected
boolean = ((x<100) &&(x>1)) ||(x<0);
^



public class numOne
{
public static void main(String[] args)
{
boolean x=10;
boolean = ((x<100) &&(x>1)) ||(x<0);
System.out.println (x);

}
}




2). Suppose s1 and s2 are two strings. Which of the following statements or expressions are incorrect?

a)String s3 = s1 - s2;
b)int i = s1.compareTo(s2);
c)char c = s1[0];
d)char c = s1.charAt(s1.length() - 1);
e)a and c.

3) Which of the loop statements always have their body executed at least once?
a)The while loop
b)The do-while loop
c)The for loop
d)None of the above

4).



User is offlineProfile CardPM
+Quote Post

horace
RE: Boolean ?'s And Others
18 Mar, 2007 - 11:05 PM
Post #2

D.I.C Addict
Group Icon

Joined: 25 Oct, 2006
Posts: 573



Thanked: 5 times
Dream Kudos: 50
My Contributions
in
CODE

boolean x=10;

you declare of boolean x and assign an int to it?
CODE

boolean = ((x<100) &&(x>1)) ||(x<0);

you decare the type boolean but no variable ?
why don't you write a program and see if you fix it?

the other look like questions from a test - what do you think the answers are?

This post has been edited by horace: 18 Mar, 2007 - 11:07 PM
User is offlineProfile CardPM
+Quote Post

ravipamuru
RE: Boolean ?'s And Others
19 Mar, 2007 - 12:53 AM
Post #3

New D.I.C Head
*

Joined: 1 Feb, 2007
Posts: 3


My Contributions
QUOTE(horace @ 19 Mar, 2007 - 12:05 AM) *

in
CODE

boolean x=10;

you declare of boolean x and assign an int to it?
CODE

boolean = ((x<100) &&(x>1)) ||(x<0);

you decare the type boolean but no variable ?
why don't you write a program and see if you fix it?

the other look like questions from a test - what do you think the answers are?


public class numOne
{
public static void main(String[] args)
{
int x=10;
if((x<100) &&(x>1) || (x<0))
System.out.println (x);
else
System.out.println(" out of range ");

}
}

QUOTE(ravipamuru @ 19 Mar, 2007 - 01:51 AM) *

QUOTE(horace @ 19 Mar, 2007 - 12:05 AM) *

in
CODE

boolean x=10;

you declare of boolean x and assign an int to it?
CODE

boolean = ((x<100) &&(x>1)) ||(x<0);

you decare the type boolean but no variable ?
why don't you write a program and see if you fix it?

the other look like questions from a test - what do you think the answers are?


public class numOne
{
public static void main(String[] args)
{
int x=10;
if((x<100) &&(x>1) || (x<0))
System.out.println (x);
else
System.out.println(" out of range ");

}
}


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 06:13PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month