In Java, tokens are the smallest units of code that have meaning in the language. They are the building blocks of Java programs and can be categorized into several types: 1. Keywords Keywords are reserved words in Java that have special meanings in the language. They cannot be used as identifiers (names for variables, methods,…
public class A { static int print(int a) { System.out.println(“I am print function”); return 10; } static void print2() { System.out.println(“I am print function2”); } static void print3(int a) { System.out.println(“I am print function3”); //return 10; } static int print4() { System.out.println(“I am print function4”); return 10; } public static void main(String[] args) { int…
public class OperatorDemo { public static void main(String[] args) { // Variable Declaration int a = 10; int b = 5; boolean result; // Arithmetic Operators int sum = a + b; int difference = a – b; int product = a * b; int quotient = a / b; int remainder = a %…
Inheritance is a fundamental concept in object-oriented programming (OOP) that allows one class to inherit the properties and behaviors (fields and methods) of another class. In Java, there are several types of inheritance, each serving a different purpose: 1. **Single Inheritance**: In single inheritance, a class (the subclass or derived class) inherits from only one…
In Java, tokens are the smallest units of a program that have a meaning. They are the building blocks of the Java programming language. When you write Java code, the compiler breaks it down into these tokens for further analysis and processing. The main types of tokens in Java are: Keywords: These are reserved words…
Encapsulation is one of the fundamental concepts of object-oriented programming (OOP) in Java. It is the technique of bundling the data (variables) and the methods (functions) that operate on the data into a single unit, called a class. Encapsulation is used to hide the internal state of an object from the outside world and only…
Java Notes java5 java4 java3 java1
Download PDF java 7
src/ └── studentinfo/ └── Student.java └── Main.java package studentinfo; public class Student { private String name; private int rollNo; private double marks; // Constructor public Student(String name, int rollNo, double marks) { this.name = name; this.rollNo = rollNo; this.marks = marks; } // Method to print student details public void printDetails() { System.out.println(“Name: ”…
public class OuterClass { private static String staticMessage = “Static message from OuterClass”; private String nonStaticMessage = “Non-static message from OuterClass”; // Static nested class static class StaticNestedClass { void display() { // Accessing static member of OuterClass System.out.println(“Accessing from StaticNestedClass: ” + staticMessage); // Cannot access non-static members of OuterClass // System.out.println(“Non-static message: ”…