Q:

What is the proper naming convention for instance variables?

In my introductory programming course, my teacher always uses the following naming convention when declaring instance variables in his code:
public class Snowman {
    private Ellipse _top;
    private Ellipse _middle;
    private Ellipse _bottom;

public Snowman() {
        _top = new Ellipse();
        _top.setColor(Color.WHITE);
        _top.setFrameColor(Color.BLACK);
        _top.setFrameThickness(1);
        _top.setSize(80, 80);
        _middle = new Ellipse();
        _middle.setColor(Color.WHITE);
        _middle.setFrameColor(Color.BLACK);
        _middle.setFrameThickness(1);
        _middle.setSize(120, 120);
        _bottom = new Ellipse();
        _bottom.setColor(Color.WHITE);
        _bottom.setFrameColor(Color.BLACK);
        _bottom.setFrameThickness(1);
        _bottom.setSize(160, 160);
    }
} 

In the course textbook, however, instance variables do not start with an underscore, but rather follow the same naming convention as that of primitive type variables (int revolutionsPerMinute). When I did an online search, I found several sources, including the online Javadoc, that cited the same convention as my textbook. As I could not reproduce the naming conventions my teacher follows, I am skeptical as to whether his convention is legitimate. Is the convention taught my teacher even existant, if not widely accepted?  

A:

Normally the standard convention in Java is camel case where you start the variable with lower case and using upper case for the first letter of every other word. For example: 
int myVariable; 
int mySecondVariable;

But note that these are conventions not rules. So anyone is free to use any convention, but it is recommended to use the standard convention to make the code readable for anyone.

A:

Class names and Types
First caps: SomeClassName, URL (acronym)
Static, Instance Variables and Methods
Camel case: thisIsCamelCase.
Constants
All caps: A_CONSTANT
Packages
All lowercase: javax.swing.jfilechooser

A:

I'd say convention is something that you follow while writing your code for the ease of the writing of the code. I don't think there is anything such as existent or non-existent convention. However, the classes you make may be used by other programmers too. So, they might have problems if they don't know the convention that you have followed. It is therefore suggested that you follow the naming convention followed by most java programmers:
int myFirstNumber;
ClassName objectName;

So, it is up to you to select the convention but I recommended following the standard that has been mentioned in the javadoc and your textbook.

