Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MindQ test ERROR Q 14 !!!!!!!!!!!!?

 
Ivan Ivanoff
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi - here is question # 14 from MindQ test:
14. Given the variable declarations below:
byte myByte;
int myInt;
long myLong;
char myChar;
float myFloat;
double myDouble;
Which one of the following assignments would need an explicit cast?
a) myInt = myByte;
b) myInt = myLong;
c) myByte = 3;
d) myInt = myChar;
e) myFloat = myDouble;
f) myFloat = 3;
g) myDouble = 3.0;
I think (a,d,f) are correct, but MinQ thinks that only (a,f) are correct !!?
I tested it with compiler like :
int a = 10;
char b = 'x';
a=b;
and it compiles just fine without any cast!!!
Is it MindQ mistake ? What do u think ?
Thank you.
Ivan.
 
Jim Hall
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer is b & e. All the rest do not require a cast. Assigning a char to an int is perfectly fine.
 
Ivan Ivanoff
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OPSSSSSS !
I was taking tests for 3 hours now & I need some rest - i completely REVERSED THIS QUESTION ! )))
Thank you !!!
Ivan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic