I.T. Discussion Community!
-Collapse +Expand
Java
Search Java Group:

Advanced
-Collapse +Expand Java To/From
To/FromCODEGuides
-Collapse +Expand Java Store
PRESTWOODSTORE
   ► KBTo/From GuidesReferenceLanguage Basics  All Groups   Print This   

Case Sensitivity (Cross Ref > Language Basics)

Case Sensitivity

Languages Focus

Case sensitiviy in this case is referring to commands and variable names. For example, are "printf" and "PrintF" equivalent? Are fullname and FullName equivalent? When you create commands, operations, methods, or variables should you worry about case?

Access VBA:   No

Access VBA is not case sensitive. Like VB Classic, if you type any other case for command or variable names, Access VBA will change it to the "accepted" or "defined" case. For example, if you type msgbox it is converted to Msgbox.

Syntax Example:

The following code works:

MsgBox ("hello")


Linked Certification Question(s)

The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.

Beginner

1 Beginner Level Question

Question #1: True or False?

Access VBA is not case sensitive. If you type any other case for command or variable names, Access VBA will change it to the "accepted" or "defined" case.

Answer:
  • True
  • False
  • More Info

     

    ASP Classic:   No

    ASP Classic is not case sensitive. My preference for all languages where case sensitivity does not matter is to use camel caps as in the first example above. Many developers coming from a case sensitive language prefer to use all lowercase.

    Syntax Example:

    You can use any of the following:

    Response.Write "Hello"
    response.write "Hello"
    RESPONSE.WRITE "Hello"
    REsponse.WritE "Hello"


    Linked Certification Question(s)

    The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.

    Beginner

    1 Beginner Level Question

    Question #1: Multiple Choice

    Which code snippet is syntactically correct?

    Answer:
    1. 
    Dim MyName
      
    MyName = "Nathan"
    Response.Write "Hello " & MyName
    2. 
    Dim MyName
      
    MYNAME = "Nathan"
    RESPONSE.WRITE "Hello " & MYNAME
    3. 
    Dim MyName
      
    myname = "Nathan"
    response.write "Hello " & myname
    4. 

    All of the above.

    5. 

    None of the above.

    More Info

     

    C#:   Yes

    In C# commands and variable names are case sensitive. The following does NOT:

    messagebox.Show("hello");  //Does not compile!

    The first time you type any other case for commands or variables, VS.Net will change it to the accepted or defined case. For example, if you type messagebox.show it is converted to MessageBox.Show. Once corrected, you can break it again by editing MessageBox to messagebox and the compiler will give you an error.

    Syntax Example:

    The following code works:

    MessageBox.Show("hello");

    Wrong Cased Variables Give Compiler Error

    If you declare a variable with one case and attempt to use it with another case, you'll get a compiler error.

    For example:

    String MyName;
      
    myname = "Felicia";   //Compiler error.
    MessageBox.Show("Hello " + MyName);

    Using Same Named-Different Cased Variabes

    You can have the same named variable with an alternate case. Although not the best idea, the following does work:

    String MYNAME;
    String MyName;
      
    MYNAME = "Nathan";
    MyName = "Felicia";
    MessageBox.Show("Hello " + MYNAME); //Shows Nathan.
    MessageBox.Show("Hello " + MyName); //Shows Felicia.


    Linked Certification Question(s)

    The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.

    Beginner

    1 Beginner Level Question

    Question #1: True or False?

    In C# you can declare and use a variable spelled the same but with a different case as in the following:

    Int16 InvoiceNumber;
    Int16 INVOICENUMBER;
      
    InvoiceNumber = 1001;
    INVOICENUMBER = 1002;
      
    MessageBox.Show("" + InvoiceNumber);
    MessageBox.Show("" + INVOICENUMBER);
    Answer:
  • True
  • False
  • More Info

    C++:   Yes

    C++ is case sensitive. In C and C++ commands and variable names are case sensitive.

    Syntax Example:

    The following first standard C++ snippet works:

    printf("hello\n");
     
    Printf("hello\n"); //>>>Does not work!

    More Info

    C++/CLI:   Yes

    Same as standard C++. Both are case sensitive. In C and C++ commands and variable names are case sensitive.

    Syntax Example:

    The following first C++/CLI snippet works:

    MessageBox::Show("Hello");
     
    messagebox::SHOW("Hello"); //>>>Does not work!

    More Info

    Corel Paradox:   No

    ObjectPAL is not case sensitive. My preference for ObjectPAL is to follow the camel casing promoted in the examples and help files originally developed by Borland.

    Syntax Example:

    All of the following are equivalent:

    msgInfo "", "Hello"
    MsgInfo "", "Hello"
    msginfo "", "Hello"
    MSGINFO "", "Hello"

    Variables are not case sensitive.

    Var
    FullName String
    endVar
    fullname="Mike Prestwood"
    msgInfo("", fullNAME)


    Linked Certification Question(s)

    The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.

    Beginner

    1 Beginner Level Question

    Question #1: Yes or No?

    With regard to commands and variable names, is ObjectPAL case sensitive?

    Answer:
  • Yes
  • No
  • More Info

    Definition:  Camel Casing
     


    More Info

    FAQ:  Camel versus Pascal Casing

    Delphi:   No

    Object Pascal is generally not case sensitive.

    Syntax Example:

    Variables and commands are not case sensitive.

    var
    FullName: String;
    begin
    fullname := 'Mike Prestwood';
    ShowMessage(fullNAME);
    SHOWMESSAGE(FULLNAME);
    showmessage(fullname);
    end;

    Cannot Declare Different Cased Variables

    The compiler will not let you compile two variables within the same scope with the same name even with different case:

    var
      MyName : String;
      MYNAME : String; //Compiler error!

    Wrong Cased Variables Legal

    Although you probably should stick with consistent casing, it is legal. If can declare a variable with one case and to use it with another case.

    For example:

    //The following mixed case varialbes work:
    var
    MyName : String;
    begin
    myname := 'Lisa';
    ShowMessage('Hello ' + MYNAME);
    end;


    Linked Certification Question(s)

    The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.

    Beginner

    1 Beginner Level Question

    Question #1: True or False?

    In Delphi you can declare and make use of same named-different case variables (two distinct variables) as in the following:

    MyName : String;
    MYNAME : String;
    Answer:
  • True
  • False
  • More Info

    FAQ:  Camel versus Pascal Casing
     
    ,

    More Info

    Definition:  Camel Casing

    Delphi Prism:   No

    Prism is generally not case sensitive. Commands and variable names are not case sensitive.

    Note: Prism (and Delphi for .Net) do not automatically match your typed case with the defined case as C# and VB.Net do within the Visual Studio Shell.

    Syntax Example:

    The following demonstrates command and variable case insensitiviy.

    var
     FullName: String;
    begin
     fullname := 'Mike Prestwood';
     MessageBox.Show(fullNAME);
     MESSAGEBOX.SHOW(FULLNAME);
     messAGEbox.sHow(fullname);
    end;


    Linked Certification Question(s)

    The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.

    Beginner

    1 Beginner Level Question

    Question #1: True or False?

    In Prism you can declare and make use of same named-different case variables (two distinct variables) as in the following:

    MyName : String;
    MYNAME : String;
    Answer:
  • True
  • False
  • More Info

     

    Java:   Yes

    Java is case sensitive.

    Customary casing:

    • Classes - Initial Caps (Pascal Casing)
    • Variables - Initial lowecase (Camel case)
    • Methods - Initial lowecase (Camel case)
    More Info / Comment

    More Info

    FAQ:  Camel versus Pascal Casing
    ,

    More Info

    Definition:  Camel Casing

    JavaScript:   Yes

    JavaScript is case sensitive. Change the case, and it no longer works! Notice the "W" in "Write" is capitalized.

    <script language=JavaScript> 
    <!--
    document.Write("Hello"); //Does not work!
    //-->
    </script>

    Variable names are case sensitive.

    Syntax Example:

    This does work:

    <script language=JavaScript> 
    <!--
    document.write("Hello");
    //-->
    </script>

    More Info

    Perl:   Yes

    Perl is case sensitive.

    Syntax Example:
    print "hello"; //This works.
    Print "hello"; //This does not.

    More Info

    PHP:   Yes and No

    PHP is case sensitive with variable names but not with commands. Although commands are case incenstive, I prefer to use all lowercase because it's easy to type and that's what I see most PHP coders doing and I see it on PHP.Net.

    Syntax Example:

    All of the following are equivalent:

    echo "hello<br>";
    ECHO "hello<br>";
    Echo "hello<br>";
    eCHo "hello<br>";

    ...but variables are case sensitive:

    $fullname = "Mike Prestwood"; //These are two...
    $FullName = "Wes Peterson";   //separate varialbes.

    More Info

    VB Classic:   No

    VB Classic is not case sensitive. If you type any other case for commands or variables, VB Classicwill change it to the "accepted" or "defined" case. For example, if you type msgbox it is converted to MsgBox.

    Syntax Example:

    The following code works:

    MsgBox ("hello")

    More Info

    VB.Net:   No

    VB.Net is not case sensitive. If you type any other case for commands or variables, VB.Net will change it to the accepted or defined case. For example, if you type messagebox.show it is converted to MessageBox.Show.

    Syntax Example:

    The following code works:

    MessageBox.Show("hello")


    Linked Certification Question(s)

    The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.

    Beginner

    1 Beginner Level Question

    Question #1: True or False?

    In VB.Net you can declare and make use of same named-different case variables as in the following:

    Dim MyName As String
    Dim MYNAME As String
    Answer:
  • True
  • False
  • More Info

     




    -
      Load Time=less than 1 second.
     
    Print This


    -
     
    Have a question? Need our services? Contact us now.
    --Mike Prestwood

    Call: 916-726-5675

    email: info@prestwood.com


    556 People Online Now!!  
    Sign In to see who's online now!  Not a member? Join now. It's free!
    Show more stats...
    Follow PrestwoodBoards on: 


    ©1995-2014 PrestwoodBoards  [Security & Privacy]
    Professional IT Services: Coding | Websites | Computer Tech