• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

JDK 1.2 or 1.3 for SCJP

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
my self sachin .
i am preparing for SCJP and shedule to give on 18 june
There is a big confusion :
Questions in SCJP are tested on JDK 1.2 or JDK 1.3 ???
as i have JDK 1.3 and there is ambiguity with JDK 1.2
for example
void test (byte x)
{
switch (x)
{
case 'a' : // complies with a on JDK 1.3 but not on JDK 1.2
case 256:
case 0 :
default :
case 80 :
}
}
so please let me know which JDK is to be used JDK 1.2 or 1.3 ??
please reply urgently as i have to prepare .
regards
sachin
------------------

------------------
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is nothing in the test that is dependent on any differences between 1.2 and 1.3.
Your example:
void test (byte x)
{
switch (x)
{
case 'a' : // complies with a on JDK 1.3 but not on JDK 1.2
case 256:
should cause a compiler error according to the Language Spec. since a byte can't have a value of 256. When in doubt, go with the language specification, not the peculiarities of any particular compiler.
For example - most compilers won't object if you declare a class using the synchronized keyword, but don't answer questions on the test that way.
Bill

------------------
author of:
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys,
I'd like to ask Bill to get "Yes" or "No" only answer.
Questions in SCJP are tested on JDK 1.2 or JDK 1.3 ???
Sachin gave you example where you can easily find the "trap":
the 256 is out of byte range.But I am using JQ+ simulator and one of the question is:
The following will compile and run without any problems:
public void switchTest(byte x){
switch(x){
case 'b': //1
default : //2
case -2: //3
case 80: //4
}
}
My answer was false. Simulator says: it works fine under JDK1.3.
So, should I expect such version dependent questions on real exam?
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The release of SDK 1.3 did not change the way the switch statement works. All of the case values in the example:
public void switchTest(byte x){
switch(x){
case 'b': //1
default : //2
case -2: //3
case 80: //4
}
}
are in the legal -128 to 127 range for byte.
(If that was a type char, it should not compile since char can't hold the value -2)
Questions are based on the language specification and the standard library classes for the Java 2 Platform, not any specific release. IF there is a conflict between the JLS and what you observe a particular compiler/JVM allowing, go with the JLS!
For example, I have heard that you can get a main method to work even if it is declared:
protected static void main(String[] args)
BUT that is NOT the way to answer a question about the declaration of main on the test.
Bill
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The exam is based on jdk1.2
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic