• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Primitive Casting Exercise

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found these questions over at JavaOnline.
I'm simply looking to confirm my answers for this exercise.

C A S T I N G
Question No : 1) In the following class definition, which is the first line (if any) that causes a compilation error. Select the one correct answer.
char c;
int i;
c = 'A';// 1
i = c;//2
c = i + 1;//3
c++;//4
A. The line labeled 1.
B. The line labeled 2.
C. The line labeled 3.
D. The line labeled 4.
E. All the lines are correct and the program compiles
Question 2) Which line in the following code will not compile
1. byte b=5;
2. char c='5';
3. short s=55;
4. int i=555;
5. float f=555.5f;
6. b=s;
7. i=c;
8. f=i;
Question 3) Will the following code compile ?
1. byte b=2;
2. byte b1=3;
3. b*=b1;
Question No.4)In the code below what are the possivle types for variable result ?
1. byte b=11;
2. short s=13;
3. result=b*s;
1) byte, short, int, long, float, double.
2) boolean, byte, short, char, int, long, float, double.
3) byte, short, char, int, long, float, double.
4) byte, short, char.
5) int, long, float, double.
_____________________________________________
Answers:
1) c
2) 6
3) Yes
4) 5
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Jimmy,
Your answers are correct.
Gurpreet Sachdeva
For mock exams and other useful pages(including topics like bitshift operator, garbage collection,inner classes,etc) please visit: http://www.go4java.20m.com
 
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Jimmy,
Answers are correct
Good job
 
Ranch Hand
Posts: 2379
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Abosulely correct shots with 500 mph speed and from 5 meter distances....
------------------
azaman
 
reply
    Bookmark Topic Watch Topic
  • New Topic