0% found this document useful (0 votes)
23 views

22 Conas TCSC 009

The document defines key concepts in Java programming including identifiers, keywords, reserved words, and camel notation. It then provides examples of each. Keywords listed include catch, char, case, class, const, and abstract. The document also defines variables in Java, listing primitive and non-primitive data types. Primitive types include byte, short, int, long, float, double, Boolean and char while non-primitive types include classes, arrays and strings. Finally, it provides a short code example to print the characters 'Hello' and 'Welcome'.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

22 Conas TCSC 009

The document defines key concepts in Java programming including identifiers, keywords, reserved words, and camel notation. It then provides examples of each. Keywords listed include catch, char, case, class, const, and abstract. The document also defines variables in Java, listing primitive and non-primitive data types. Primitive types include byte, short, int, long, float, double, Boolean and char while non-primitive types include classes, arrays and strings. Finally, it provides a short code example to print the characters 'Hello' and 'Welcome'.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Name: OYELEKE SODIQ

Matric no: 22/CONAS/TCSC/009

Course code: TCSC 207

Course title: JAVA PROGRAMMING LANGUAGE

Assignment

1. a. Describe in your own words the following:

Identifiers

Keywords

Reserved Words

Camel Notations

Identifiers
An identifier is a name used to identify a variable, function, or any other user-defined
item. An identifier starts with a letter A to Z or a to z or an underscore _ followed by zero
or more letters, underscores, and digits (0 to 9).
C does not allow punctuation characters such as @, $, and % within identifiers. C is a
case sensitive programming language. Thus, Man and man are two different identifiers in
java programming language. Here are some examples of acceptable identifiers: mohd,
zara, abc, move_name, a_123, myname50, _temp, j, a23b9, retVal

Keywords
These reserved words may not be used as constant or variable or any other identifier
names. Java keyword are reserved terms that have special function and a set definition in
the java programming language.

Examples of keyword in java are: - catch, char, case, class, const, abstract, assert,
boolean, float, loop, goto e.t.c

RESERVED WORD
These are the words that cannot be used as object or variable names in a java program
because they are already used by the syntax of the java programming language. Examples
are import, double, null, void, try, public, new e.t.c
CAMEL NOTATIONS
Camel notation is a way to separate the words in a phrase by making the first letter of
each word capitalized and not using spaces. It is commonly used in web programming
and computer naming conventions. It is name after camels because the capital letters
resemble the humps on a camel’s back.

B. List Ten Keywords

i. Catch
ii. Char
iii. Case
iv. Class
v. Const
vi. Abstract
vii. Assert
viii. Boolean
ix. Float
x. Loop

2. Define Variables

A variable is nothing but a name given to a storage area that our programs can
manipulate. It can also be defined as data items whose value changes at the point of
execution.

Two syntax used in declarating variables in Java programming language

Syntax 1

datatype varable_name;

Examples

int x; int y; char grade; string name;

Syntax 2

datatype variable_name = intial_value;


Examples

int x =2; int y = 3; char grade = ‘A’; string name “SUMMIT”;

DATATYPE

Data types can refer to an extensive system used for declaring variables or functions of
different types. The type of a variable determines how much space it occupies in storage
and how the bit pattern stored is interpreted.

Type of Datatype

Datatype in java are divided into groups:

i. Primitive data types includes byte, short, int, long, float, double, Boolean and char
ii. Non primitive data types includes string, array and classes

i. Primitive data types specifies the size and type of variable values and it has no
additional methods
there are eight primitive data types in java

Data type Size description


byte 1 byte Store whole numbers from
-128 to 127
Short 2 bytes Store whole numbers from
-32, 768 to 32, 767
int 4 bytes Store whole numbers from
-2, 147, 483, 647 to
2,147,483,647
Long 8 bytes Store whole numbers from
-9,
223,372,06,854,775,808
373,036,854,775,807
Float 4 bytes Store fractional number.
Sufficient for storing 6 to7
decimal digits
Double 8 bytes Store fractional number.
Sufficient for storing 15
decimal digits
Boolean 1 bit Stores true or false
Char 2 bytes Store a single character or
letter or ASCII values
ii. Non primitive data types are used to call methods to perform certain
operations. They are also called reference types because they refer to objects.
Examples are classes, interface, arrays and strings.

THE MAIN DIFFERENCE BETWEEN PRIMITIVE AND NON-PRIMITIVE


DATA TYPES ARE:

Primitive types are predefined (already defined) in Java while Non-primitive types are
created by the programmer and is not defined by Java (except for String).

Non-primitive types can be used to call methods to perform certain operations, while
primitive types cannot.

A primitive type has always a value, while non-primitive types can be null.

A primitive type starts with a lowercase letter, while non-primitive types starts with an
uppercase letter.

The size of a primitive type depends on the data type, while non-primitive types have all
the same size.

3. public class example {

public static void main (String[])

char c1 = ‘Hello’;

char c2 = ‘Welcome’;

System.out.println(“character 1 is : ” + c1);

System.out.println(“character2 is : ” + c2);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy