• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enthuware errors

 
zach zhang
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
enthuware.ocpjp.v7.2.1619

Question 13 of test1

What will the following statement print? System.out.printf("%1$s %s %<s", "A", "B", "C");

The answer here is A B A, but the correct one should be A A A.
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3817
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Zach,

I just verified that the correct answer given is indeed A A A (Option 4) (and not A B A). There haven't been any updates to this question either so it has been like that for quite a while.
A detailed explanation is also provided with this option:

There are two things here:
1. When you don't specify the argument index or relative indexing (i.e. the < flag) in the format specifier, it means that you are using ordinary indexing. Each format specifier that uses ordinary indexing is assigned a sequential implicit index into argument list which is independent of the indices used by explicit or relative indexing.

The ordinary index starts with the first format specifier that does not use explicit index.

In this case, it starts with the middle %s. Therefore, it prints the first argument which is A.

2. < is used for relative indexing. It means you want to use the argument that was used for the previous format specifier. In this case, it was A. Therefore, it prints A again.

This is explained further here: http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html


BTW, if you find any issue/error with any question, you may just click on the Discuss button on the bottom on the question view, and it will take you to any existing discussion about that question. If there is no existing discussion, you may start a new one.
HTH,
Paul.
 
zach zhang
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my mistake...you are right.


I didn't read the q correctly. Anyway, thanks.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, I'm a java developer for 10 years now and took the programmer certification exam 3 times (each for a different java version ), but I didn't know about relative indexing and the ordinary index.

I wonder if that's not a tad too trivial for the actual certification exams...
 
zach zhang
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is an exam...

A lot of tiny stuff such as dataformat, I/O options, different file attribute stuff...
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
zach zhang wrote:This is an exam...

This is a mock exam (one of the best on the market), i was refering to the real deal, the actual Oracle certification exam.
 
zach zhang
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For ocpjp7, the difficult level of this mock exam is very similar to that of real oracle exam, according to other ranchers feedback.

That's why I postpone the exam date because my score on the mock exams are not very good. But, from the experience other ranchers shared on the result board, their mock exam scores were also not very good.

And for the string format topic, there are some tiny corner questions like this in real oracle exam.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
zach zhang wrote:And for the string format topic, there are some tiny corner questions like this in real oracle exam.

I know. Due to one of these tiny corners I missed a perfect score on my SCJP6 exam
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic