Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

errata or ??

 
R K Singh
Ranch Hand
Posts: 5384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
que is from : http://www.4tests.com/exams/questions.asp
6) Which of the following are acceptable?
[check bixes are there - RK]
Object o = new Button("A");
Frame f = new Panel();
Boolean flag = true; // 3
Boolean flag = true; // 4
Panel p = new Applet();


====
My prob is that ... I can not distinguish the diffrence betn 3 & 4 ...
is it same with every one ...
is it errata
TIA
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah I think it is an errata... Typical cut-paste problem...
I'm moving this to Mock Exam Errata
 
Moya Green
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I met the same question in John Hunt Mock exam. Could anyone explain to me why
---------------------------
Boolean flag = true; // 3
---------------------------
is not acceptable? Thanks a lot!
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because:
Boolean flag = true
tries to assign the boolean literal true to a reference variable of type Boolean (which is a class)...
boolean flag = true
and
Boolean flag = new Boolean("true")
Boolean flag = new Boolean(true)
are valid statements.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic