1.3_Understanding the Java Class Structure Flashcards
What is a keyword?
In Java a keyword is a reserved word that has a predefined meaning in the language.
What is the valid length for a Java class name?
1 - 65535 characters
What are the Java Identifier Rules?
o [A-Z],[a-z],[0-9],’‘(underscore),’$’(Dollar sign)
o Can NOT start with numbers
o Valid length 1-65535
o ⚠️Can NOT be ‘’ (a single underscore)
What is the syntax to declare a Java variable?
{Type} varName;
What is a Java method?
A Java method is a collection of statements that are grouped together to perform an operation. This operation can be invoked by its method signature multiple times avoiding to write those statements again.
What are the required elements of a method declaration ?
o The method's return type. o Method's name o A pair of parentheses (). o argument-list o ...and body statement between braces, {}
For Java methods, Is the return type mandatory?
Yes, a method must always defines its return type. And when it doesn’t return anything we use the keyword ‘void’.
Where should be placed the return type within a method declaration?
The return type goes to the immediate left of the method name.
What does void means as a return type?
void means the method wont be returning anything.
What pieces compose the method-signature?
method name + parameter-types list
What are the three kind of comments in Java?
o //single-line comment
o /Multi Line comment/
o /** *Java-doc MultiLine comment *@author Efren Diaz */
What are the valid main’s method declarations?
public static void main(String[] argsName)
public static void main(String argsName[])
static public void main(String… argsName)
*Notice that the argsName could be any valid parameter name
What are the rules for files containing a Java class definition?
o Each Java file can contain only one public class. o The filename must match the public/single class name, including case o It must have a .java extension.
How to compile a java class via Terminal?
To compile Java code, the file must have the extension .java.
$ javac ClassName.java
What is the result of compiling a Java class?
The result is a file of bytecodes with the same name, but with a .class filename extension.