jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Primitive Casting Exercise Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Primitive Casting Exercise" Watch "Primitive Casting Exercise" New topic

Primitive Casting Exercise

Jimmy Blakely
Ranch Hand

Joined: Jul 10, 2001
Posts: 57
Found these questions over at JavaOnline.
I'm simply looking to confirm my answers for this exercise.

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
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.
1) c
2) 6
3) Yes
4) 5
Gurpreet Sachdeva
Ranch Hand

Joined: Feb 20, 2001
Posts: 90
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

Regards<BR>Gurpreet Sachdeva<P>For Mock Exams, FAQ, Exam tips and some useful information about Bitshift operator, inner classes, garbage collection,etc please visit: <A HREF="http://www.go4java.lookscool.com" TARGET=_blank rel="nofollow">http://www.go4java.lookscool.com</A>
Ragu Sivaraman
Ranch Hand

Joined: Jul 20, 2001
Posts: 464
Hey Jimmy,
Answers are correct
Good job
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2373

Abosulely correct shots with 500 mph speed and from 5 meter distances....

Ashik Uzzaman
Senior Software Engineer, TubeMogul, Emeryville, CA, USA.
I agree. Here's the link: http://aspose.com/file-tools
subject: Primitive Casting Exercise
It's not a secret anymore!