Win a copy of AWS Security this week in the Cloud/Virtualization 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Are compilation error on comments part of OCAJP exam?

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider this code :

class Fizz {
public static void main(String[] args) {
char u='\u0000';
//StringB\uilder b = new StringBuilder("abcd");

}

}

At first, the code looks fine. But you get compilation error "Invalid unicode" on the comment which line 4.
My question is should we expect this kind of problem in the actual exam? Thanks in advance :-)
 
Greenhorn
Posts: 13
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I learned something new today. Unicode characters are interpreted even if it is within comments early in the compilation Comments in Java so the \u in StringBuilder throws an error. Thanks for putting out an example like this. I had never considered this type of compilation error before. As for whether they are on the exam, sorry, I can't answer that question.
 
Sheriff
Posts: 7619
522
Mac OS X VI Editor BSD Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Neha Agnihotri wrote:My question is should we expect this kind of problem in the actual exam?


No.

The very first time I got to know this when read book Java Puzzlers by Joshua Bloch and Neal Gafter, about 3 years ago, when Campbell told me to read that book.

Such type of question might be a good one as for a party trick, but wouldn't be funny at all even in OCAJP, while there you could find some quite fun stuff.
 
Neha Agnihotri
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great! That’s some relief.
Yes, I too found that book amazing.
Thanks for your reply :-)
 
He loves you so much! And I'm baking the cake! I'm going to put this tiny ad in the cake:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic