About Question enthuware.ocajp.i.v8.2.1455 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
dheeraj426
Posts: 1
Joined: Fri Sep 08, 2017 9:02 am
Contact:

About Question enthuware.ocajp.i.v8.2.1455 :

Post by dheeraj426 »

What will the following code print?

Code: Select all

int x = 1; int y = 2; 
int z = x + +; 
int a = --y; 
int b = z--; 
b + = + + z; 
int answ = x > a? y > b? y:b:x > z? x:z; 
System.out.println( answ);
Last edited by admin on Fri Sep 08, 2017 10:29 am, edited 1 time in total.
Reason: Update post to use [code] tags

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1455 :

Post by admin »

What happened when you tried it out?
Also, please put code within .
If you like our products and services, please help us by posting your review here.

Sergey
Posts: 39
Joined: Sat Jul 29, 2017 1:04 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1455 :

Post by Sergey »

Code: Select all

int answ = (x>a) ? (y>b ? y:b) : (x>z?x:z);
I did not resolve this question at the paper. As for me, it is extremely hard question.

OCAJO1
Posts: 221
Joined: Mon Nov 26, 2018 2:43 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1455 :

Post by OCAJO1 »

What would you say is good exam taking strategy for time consuming questions like this, figure them out, or leave them for the end?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1455 :

Post by admin »

If you are a beginner, then it does take some time to figure it out, so, better to leave it for the end.
If you like our products and services, please help us by posting your review here.

Nathan777
Posts: 2
Joined: Tue Oct 01, 2019 4:10 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1455 :

Post by Nathan777 »

I got pretty much this exact question with just different variable names on the exam today. Luckily, I just had it right before when I was taking this test at Panera Bread down the road from the testing center.

brintal
Posts: 6
Joined: Sun Jan 23, 2022 8:43 am
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1455 :

Post by brintal »

Is there any good strategy to quickly group the elements of nested ternary operators?

E.g. making

Code: Select all

x > a  ? (y>b ? y : b)  :  (x>z ? x : z)
out of

Code: Select all

x>a?y>b?y:b:x>z?x:z
EDIT: figured it out myself. This is a very good explanation: http://twistedoakstudios.com/blog/Post5 ... -operators

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1455 :

Post by admin »

Good link. thanks for sharing.
If you like our products and services, please help us by posting your review here.

SCOTTBART1
Posts: 1
Joined: Fri Jan 13, 2023 4:49 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1455 :

Post by SCOTTBART1 »

Obtuse and deliberately muddy questions, don't see the point, nobody codes like that.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1455 :

Post by admin »

It true that nobody codes like that but the exam does test your ability to parse through such code.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 58 guests