Skip to main content

Posts

How to pass an object as an argument in Java programming? We know that the concept of calling a method as pass by value and pass by reference. Java allows us to pass primitive types of data when calling a method that is called as 'a method call by value' or 'passed by value'. In the same manner, we can create an object by passing primitive type of data using constructors.  Java allows us to create an object by passing reference of another object ie. One Object can be passed to another object. This is called as 'call by reference' or 'passed by reference'.  Syntax     <class name> <object name1>=new <class name>;      <class name> <object name2> ;     <object name2>=<object name1>; Example Program class test {      int i;      test(int a)      {      i=a;      }      int testmethod(test t)     ...
  Identifiers, Literals, Operators and Separators in Java Programming Language Here is a clear introduction (exam-ready + student-friendly) to Identifiers, Literals, Separators, and Operators in programming (especially Java/C-style languages). 🔹 Identifiers An identifier is the name given to a variable, method, class, array, or any user-defined item in a program. It helps identify these elements uniquely. ✔ Rules for Identifiers (Java) Must begin with a letter (A–Z or a–z), underscore (_), or dollar sign ($) Cannot start with a number Cannot be a reserved keyword Case-sensitive ( total and Total are different) No spaces allowed Examples ✔ Valid Identifiers int age; double totalMarks; String studentName; int _count; ❌ Invalid Identifiers int 2value;       // starts with number int total marks; // contains space int class;        // keyword 👉 ...