• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

simple doubt with operators  RSS feed

 
Ranch Hand
Posts: 274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
source http://www.valoxo.ch/jr/mocks/mock01a.html Q48

What is the output of the following code when compiled and run? Select one correct answer.
public class Question48{
public static void main(String[] args) {
int i = 4*6-3/2<<2*5>>>1%2-4^3;
System.out.println(i);
}
}

A. Prints: 0

B. Prints: 1

C. Prints: 2

D. Prints: 3

E. Compilation error.

Ans: D
Doubt: how to solve such a question?


pls help,
Gitesh
 
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you are planning for SCJP 5.0 ,bit wise operators are nt there in sllyabus.
 
Gitesh Ramchandani
Ranch Hand
Posts: 274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I'm preparing for SCJP1.4.

Pls Help,
Gitesh
 
Java Cowboy
Sheriff
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a hard question to answer without a computer.

To answer this, you will have to know what all the operators do and in what order they are executed.

See The Java Tutorial - Operators for a detailed description. Note the Operator Precedence table on that page; it explains which operations are evaluated first.
 
Gitesh Ramchandani
Ranch Hand
Posts: 274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper,

Can i expect such a question in SCJP1.4?

Regards,
Gitesh
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!