Search Header Logo
Understanding the keywords

Understanding the keywords

Assessment

Presentation

Computers

12th Grade

Hard

Created by

Kenneth Galdo

FREE Resource

9 Slides • 0 Questions

1

Understanding the Syntax

Presented by: Kenneth Walter Galdo

Computer Programming III - JAVA OOP

2

​Basic Syntax

Case Sensitivity − Java is case sensitive, which means identifier Hello and hello would have different meaning in Java.​

Class Names − For all class names the first letter should be in Upper Case. If several words are used to form a name of the class, each inner word's first letter should be in Upper Case.

Example: class MyFirstJavaClass

3

​Basic Syntax

Method Names − All method names should start with a Lower Case letter. If several words are used to form the name of the method, then each inner word's first letter should be in Upper Case.

Example: public void myMethodName()

4

​Basic Syntax

Program File Name − Name of the program file should exactly match the class name.

When saving the file, you should save it using the class name (Remember Java is case sensitive) and append '.java' to the end of the name (if the file name and the class name do not match, your program will not compile).

​Example: Assume 'MyFirstJavaProgram' is the class name. Then the file should be saved as 'MyFirstJavaProgram.java'

5

​Reserved Word or Keywords

​it has special meaning and cannot be used in naming variables, classes, methods, or identifiers. The Java language designates certain keywords that the compiler recognizes as reserved words.

media

Understanding the keywords

6

​The basic parts of the main method are the heading and the body

  • ​The public static void main (String[] args) is called the heading.

  • ​the statements enclosed between brackets { body } form the body of the main method. It contains the declaration and execution of the program.

media

7

​Here is an explanation of meaning and purpose of the terms used in the method heading

  • The keyword public is an access modifier. Method heading should be public for the Java interpreter to call it and run the class.

  • ​The keyword static means that a method is accessible and usable.​

  • The keyword void indicates that the main method does not return any value when it is called.​

  • ​The contents between the parentheses of the main method, which is String[] args, represent the type of argument that can be passed to the main method.

8

Variable

​It is a name for a memory location that stores a specific value, such as numbers and letters. It can only hold 1 value at a time.

​data_type variable_name [= value];

​examples:

​int a = 23;

​int b = 10, b = 5 + 3;

​float f = 2.75f;

​double grade - 2.75;

​char letter = 'A';

​byte b;

​int size; size = 30;

9

​Constant

​it is a memory location whose value cannot be changed during program execution.

Syntax : final data_type variable_name = value;

final double Pi = 3.14159;

​final int squareSides = 4;

​final char blankSpace = ' ';

​final int hour_per_day; hour_per_day = 24;

Understanding the Syntax

Presented by: Kenneth Walter Galdo

Computer Programming III - JAVA OOP

Show answer

Auto Play

Slide 1 / 9

SLIDE