This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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
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
 
Oh, sure, you could do that. Or you could eat some pie. While reading this tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!