• 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

Related to SCJP

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello frdz, I want to know which compiler version should be used for compiling the program related to the exam 1Z0-851 (Java Standard Edition 6 Programmer Certified Professional).
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Version 1.6 is the compiler version for that version of the exam.
 
Aabhas Gupta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:Version 1.6 is the compiler version for that version of the exam.


Can you please tell me whether we can declared a static instance variable or not (in context of this exam).
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can declare a static instance variable in any version of Java. So yes.
 
Aabhas Gupta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:You can declare a static instance variable in any version of Java. So yes.


I read the book "scjp by kathy sierra and bert bates" in which it is clearly written that instance variable cannot be static.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Aabhas Gupta wrote:

Jeanne Boyarsky wrote:You can declare a static instance variable in any version of Java. So yes.


I read the book "scjp by kathy sierra and bert bates" in which it is clearly written that instance variable cannot be static.


Oh. *instance* variable. I didn't read carefully (or think). I was thinking about static class variables. Yeah, instance variables can't be static.
 
Aabhas Gupta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh. *instance* variable. I didn't read carefully (or think). I was thinking about static class variables. Yeah, instance variables can't be static.
But as you said the compiler version should be 1.6. When I am compiling the program with the javac 1.6.0_45, compiler doesn't showing any error. Why?
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Aabhas Gupta wrote:
But as you said the compiler version should be 1.6. When I am compiling the program with the javac 1.6.0_45, compiler doesn't showing any error. Why?



Well, it would help if you showed us what code you actually compiled....

Henry
 
Aabhas Gupta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

Aabhas Gupta wrote:
But as you said the compiler version should be 1.6. When I am compiling the program with the javac 1.6.0_45, compiler doesn't showing any error. Why?



Well, it would help if you showed us what code you actually compiled....

Henry


Simply I have created a class and declared the static variable as static int a;
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Aabhas Gupta wrote:  
Simply I have created a class and declared the static variable as static int a;



That should work fine. Why did you expect a compile error?

Henry
 
Aabhas Gupta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

Aabhas Gupta wrote:  
Simply I have created a class and declared the static variable as static int a;



That should work fine. Why did you expect a compile error?

Henry


Because I have read in the book scjp by kathy cierra that "an instance variable cannot be static".
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Aabhas Gupta wrote:
Because I have read in the book scjp by kathy cierra that "an instance variable cannot be static".



That line declares a static variable -- and static variables are... well... static.

Henry
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic