• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

need help

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello everybody
i am an engineering graduate and while i am waiting for my placement , which got delayed due to obvious reasons , i have about the end of this month to appear for the SCJP exam . i am preparing from the mughal book . although the book is excellent i still cant take any chances , so please tell me java gods , what exactly do i need to do to get this certification right first time . im not much comfortable with threads , packages and havent studied awt , layout , event handling , painting , applets and swing previously , and the khalid mughal book has a major chunk consisting of these topics . please tell me what is the percentage of questions asked from these parts . also what may be the trend in current exams and has the syllabus changed from what it was in january ? any tips will be held sacred , so please help me out . also in the case of not passing the exam , ill send my pics to this forum , which will haunt future newcomers and past greenhorns . and dont worry bartenders , u will get a lion's share of them if u dont include my mail .
kidding apart , there is a question in the book where
k=1;
i= ++k + k++ + + k;
in the answer section , the problem is solved as
(++k) + (k++) + (+k) = 2+2+3
but isnt the postfix operator is at higher priority comapred to prefix one . then in that case , the answer should be
++k + (k++) + +k
(++k) + 1 + +k {k==2}
3 + 1 + 3 {k==3}
any suggestions on what shopuld be the correct way ?
 
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java evaluates expressions from left to right.
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(++k) + (k++) + (+k) = 2+2+3
Why does (+k) = 3?
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Cameron,
Do you mean to say the evaluation is always from left to right?
Can you please explain this to me?
class test
{
public static void main(String[] args)
{
int i = 10;
int j = 10;
boolean b = false;

System.out.println(b=i==j);
}
}
I am a bit confused and would appreciate if anybody could help.
Thanks,
Rashmi
 
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rashmi,
what you are trying to do is assignment, which goes from right to left. Expression goes from left to right.
--Farooq
 
Rashmi Hosalli
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Muhammad,it really helped!
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Muhammad Farooq:
Hi Rashmi,
what you are trying to do is assignment, which goes from right to left. Expression goes from left to right.
--Farooq


but i= ++k + k++ + + k; is also assigning to variable i,please explain me clearly in what case left to right and right to lefe with complex examples
 
All that thinking. Doesn't it hurt? What do you think about this tiny ad?
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic