diff --git a/source/ch2_firstjavaprogram.ptx b/source/ch2_firstjavaprogram.ptx index c1cb7a1..7f1669d 100644 --- a/source/ch2_firstjavaprogram.ptx +++ b/source/ch2_firstjavaprogram.ptx @@ -526,4 +526,88 @@ Hello World! + +
+ Naming Conventions +

+ It is worth pointing out that Java has some very handy naming conventions. It is advisable to both use meaningful names and to follow these naming conventions while developing software in Java for good maintenance and readability of code. +

+ +

+

+

+ + + +

+ Which of the following is a valid variable name according to the core syntax rules of Java, but causes a syntax error in Python? +

+
+ + + _variableName + +

+ Incorrect. Leading underscores are valid in both Java and Python (commonly used in Python for private/protected attributes). +

+
+
+ + + variable_name + +

+ Incorrect. Snake_case names with underscores are valid in both languages (and are actually standard convention in Python). +

+
+
+ + + $variableName + +

+ Correct! Java allows the dollar sign ($) in variable names, but Python generates a SyntaxError because $ is not a permitted identifier character in Python. +

+
+
+ + + variableName2 + +

+ Incorrect. Numbers at the end of variable names are valid syntax in both Java and Python. +

+
+
+
+
+ +
+ \ No newline at end of file diff --git a/source/ch3_javadatatypes.ptx b/source/ch3_javadatatypes.ptx index df08c4a..62365f8 100644 --- a/source/ch3_javadatatypes.ptx +++ b/source/ch3_javadatatypes.ptx @@ -1126,88 +1126,7 @@ public class HistoMap { -
- Naming Conventions -

- It is worth pointing out that Java has some very handy naming conventions. It is advisable to both use meaningful names and to follow these naming conventions while developing software in Java for good maintenance and readability of code. -

- -

-

-

- - - -

- Which of the following is a valid variable name according to the core syntax rules of Java, but causes a syntax error in Python? -

-
- - - _variableName - -

- Incorrect. Leading underscores are valid in both Java and Python (commonly used in Python for private/protected attributes). -

-
-
- - variable_name - -

- Incorrect. Snake_case names with underscores are valid in both languages (and are actually standard convention in Python). -

-
-
- - - $variableName - -

- Correct! Java allows the dollar sign ($) in variable names, but Python generates a SyntaxError because $ is not a permitted identifier character in Python. -

-
-
- - - variableName2 - -

- Incorrect. Numbers at the end of variable names are valid syntax in both Java and Python. -

-
-
-
-
- -
Summary & Reading Questions