• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

char doubt

 
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public static void main(String[] args){
02: char c = '\u0042';
03: switch(c) {
04: default:
05: System.out.println("Default");
06: case 'A':
07: System.out.println("A");
08: case 'B':
09: System.out.println("B");
10: case 'C':
11: System.out.println("C");
12: }
13: }


Prints - Default , A , B , C
Prints - A
Prints - B , C-answer
Prints - A, B , C , Default
Prints - Default

How do I know char c = '\u0042' =B. Do I except this kind of example in real exam?
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I really don't think this kind of question will come in scjp 1.5 where you need to remember unicodes!
 
Ranch Hand
Posts: 274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dolly,

I think you got tis question from some old mock. Such questions are not expected in current exam.

Gitesh
 
Been there. Done that. Went back for more. But this time, I took this tiny ad with me:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic