This document provides an overview of key Java concepts including classes, methods, modifiers, datatypes, operators, comparison operators, logical operators, and if statements. A class contains methods that define the behavior and actions of an object. Methods contain the logic and code to manipulate data. The document describes public, private and protected modifiers that control access to code. It also defines common Java datatypes like String, int, float, char, and boolean and basic operators for arithmetic, comparison, and logical operations. If statements allow code to be conditionally executed based on true or false evaluations.
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
14 views
Understanding Java
This document provides an overview of key Java concepts including classes, methods, modifiers, datatypes, operators, comparison operators, logical operators, and if statements. A class contains methods that define the behavior and actions of an object. Methods contain the logic and code to manipulate data. The document describes public, private and protected modifiers that control access to code. It also defines common Java datatypes like String, int, float, char, and boolean and basic operators for arithmetic, comparison, and logical operations. If statements allow code to be conditionally executed based on true or false evaluations.
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 9
Understanding
Java Language Lesson Overview:
Understanding Java Class, Method,
Modifiers, Datatypes, Basic Operators, Comparison Operators, Logical Operators, If Statement. Java Class & Method
Class − A class can be defined as a
template/blueprint that describes the behavior/state that the object of its type supports.
Methods − A method is basically a behavior. A
class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed. Java Modifier Public - The code is accessible for all classes. Private - The code is only accessible within the declared class. Protected - The code is accessible in the same package and subclasses. Java Datatypes/Variable Types String - Stores text, such as "Hello". String values are surrounded by double quotes. Int - stores integers (whole numbers), without decimals. Float - stores numbers, with decimals. Char - stores single characters, such as 'a' or 'B'. Char values are surrounded by single quotes. Boolean - stores values with two states: true or false. Java Basic Operators + (Addition) - Adds values on either side of the operator. - (Subtraction) - Subtracts right-hand operand from left- hand operand. *(Multiplication) - Multiplies values on either side of the operator. / (Division) - Divides left-hand operand by right-hand operand. % (Modulus) - Divides left-hand operand by right-hand operand and returns remainder. ++ (Increment) - Increases the value of operand by 1. -- (Decrement) - Decreases the value of operand by 1. Java Comparison Operators Equal to ( == ) Not equal ( != ) Greater than ( > ) Less than ( < ) Greater than or equal to ( >= ) Less than or equal to ( <= ) Java Logical Operators Logical and ( && ) Logical or ( || ) Logical not ( ! ) Java If Statement if (condition) { } ----------------------------------------------- if (condition) { // block of code to be executed if the condition is true } else { // block of code to be executed if the condition is false } ----------------------------------------------- if (condition1) { // block of code to be executed if condition1 is true } else if (condition2) { // block of code to be executed if the condition1 is false and condition2 is true } else { // block of code to be executed if the condition1 is false and condition2 is false }