Posts

12. Types of Operator part2

  6. Conditional Operator Also known as the ternary operator, it returns one of two values based on a condition. Ternary (?:) : If condition is true, return value1; else, return value2. int max = (a > b) ? a : b; // max is 5 7. Compound Assignment Operator These combine an arithmetic operation with assignment. Add and assign (+=) : Adds right operand to the left operand and assigns the result to the left operand. a += b; // a becomes 8 (5 + 3) Subtract and assign (-=) : Subtracts right operand from the left operand and assigns the result to the left operand. a -= b; // a becomes 2 (5 - 3) 8. Increment and Decrement Operator These are used to increase or decrease the value of a variable by 1. Increment (++) : Increases value by 1. a++; // a becomes 6 Decrement (--) : Decreases value by 1. a--; // a becomes 4 9. Miscellaneous Operator Other useful operators. Instanceof : Checks if an object is an instance of a specific class or subclass. String str = "Hello" ; boo...

11. Types of Operator part1

  1.  Arithmetic Operators These are used to perform basic mathematical operations. Addition (+) : Adds two numbers. int a = 5 ; int b = 3 ; int sum = a + b; // sum is 8 Subtraction (-) : Subtracts one number from another. int difference = a - b; // difference is 2 Multiplication (*) : Multiplies two numbers. int product = a * b; // product is 15 Division (/) : Divides one number by another. int quotient = a / b; // quotient is 1 Modulus (%) : Gives the remainder of a division. int remainder = a % b; // remainder is 2 2.   Relational Operators These are used to compare two values. Equal to (==) : Checks if two values are equal. boolean isEqual = (a == b); // isEqual is false Not equal to (!=) : Checks if two values are not equal. boolean isNotEqual = (a != b); // isNotEqual is true Greater than (>) : Checks if one value is greater than another. boolean isGreater = (a > b); // isGreater is true Less than (<) : Checks if one v...

10. String and Operators.

Image
 String Strings in Java are a crucial aspect of programming, as they allow for the manipulation and handling of text. Here’s a detailed explanation of strings, their characteristics, and how they can be created and used in Java. Characteristics of Strings in Java String Class : String is a predefined class in Java, derived from the java.Lang package. It is a non-primitive data type because it is a class. A String is a collection of characters enclosed within double quotes ( " " ). Immutability : Strings in Java are immutable, meaning once a String object is created, its value cannot be changed. Creating Strings in Java There are two main ways to create a string in Java:        1.  Using String Literals : When a string is created using string literals, it is stored in the String Constant Pool (SCP)                                            ...

9. Variable types And Characteristics .

 Variable Types 1) Global Variable - Global Variable are declared in class block are known as Global Variable. They are classified as 2 types : -                                              1) static Variable                                              2) Non-Static Variable 2) Local Variable - The Variable which are declared in method block inside method block expect class block called as local variable. Characteristic of local variable -  1)  Variable declared inside a block remain accessible to that block only cannot accessible from outside the block. If we accessed it from outside block,  it will get compile time error.  ex - class example           {                ...

8. Datatype and Variable

Image
Datatype It is a container where we create variable to store data. There are two types of datatypes :- 1) Primitive Datatype :- Primitive datatype helps the programmer to create primitive type variables which helps us to store primitive data. 2) Non-Primitive Datatype :-  Unlike primitive data types, these are not predefined. These are user-defined data types created by programmers. These data types are used to store multiple values. There are five types of non-primitive data types in Java. They are as follows: Class Object String Array Interface Variable Variables are the container where we store data in java we create variable with the help of datatypes. [Note - In java we cannot use a variable without declaring.] Syntax - Datatype variablename ;                byte age ; Variable Initialization statement :-  Assigning value to create variable is known as variable initializing statement. ex - age = 10 ; grade = '*' ; salary = 5.00.0...

7. Tokens and Industry Standards.

Image
 Tokens  Tokens are the smallest unit of java programming language. They are classified into two types: - 1) Keyword's 2) Identifiers  let's learn them in detail....... 1.  Keywords  - The words which are aware by the compiler are known as keywords.  - They have pre-defined meaning, and we cannot alter (change) them.  - There are 50+ keywords in java.  -  Every keyword must be written in lower case. The below table is the list for keywords.    2.  Identifier    Identifiers are names given by the programmer to various elements in a Java program.  These elements can include classes, interfaces, variables, methods, packages, Enums, and more.   Examples of identifier 1)   Class Names: 'class MyClass { ... }' 2)   Interface Names: 'interface MyInterface { ... }' 3)   Variable Names: 'int myVariable = 10;' 4)    Method Names: 'public void myMethod() { ... }' 5)  ...

6. Basic Commands for command prompt and Basic java program

Command Line Interface Commands for Using Command Prompt - Here are some common commands used in the Command Prompt: 'dir' Lists the contents of the current directory. Example: ' dir' 'cls' Clears the screen. Example: ' cls' 'cd' Changes the directory from the current folder to a specified folder. Example: ' cd foldername' 'cd..' Moves up one directory level from the current folder to the parent folder. Example: ' cd..' 'drive name:' Changes the drive. Example: '  C:' 'mkdir' or ' md' Creates a new folder in the current directory. Example: ' mkdir foldername' or ' md foldername' 'javac -version' Checks the version of the Java compiler. Example: ' javac -version' 'java -version' Checks the version of the Java Virtual Machine (JVM). Example: ' java -version' These commands will help you navigate and manage directories, check Java versions, and ...