• Home
  • Blog
  • 2.1 Which of the following are legal identifiers? Why? Greeting1 g void 104IT IT104 Hello, World   Hello3World           2.2 Construct a logical expression to represent each of the following conditions: a. x…

2.1 Which of the following are legal identifiers? Why? Greeting1 g void 104IT IT104 Hello, World   Hello3World           2.2 Construct a logical expression to represent each of the following conditions: a. x…

0 comments

2.1 Which of the following are legal identifiers? Why?

Greeting1

g

void

104IT

IT104

Hello,

World

 

Hello3World

 

 

 

 

 

2.2 Construct a logical expression to represent each of the following

conditions:

a. x is between 3 and 15 but not equal to 10.

b. x is between 10 and 20 but not odd.

c. y is divisible by 5 but not by 40.

d. str is a lowercase or uppercase letter.

2.3 What is the difference between the following two statements?

a. if (n > 2) { if (n < 6) System.out.println(“Done!”); }

 else System.out.println(“Error”);

b. if (n > 2) { if (n < 6) System.out.println(“Done!”);

 else System.out.println(“Error”); }

2.4 What is the difference between the result of the following two statements?

a. int cents = (int)(100 * price + 0.5);

 

b. int cents = (100 * price + 0.5);

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}