Skip to main content

Posts

Showing posts with the label object passing examples in java

What are Objects In Java Programming

 Java Programming Objects   Object name in java is a reference  References are used to store address   All objects created in heap with new statement   There is no delete statement in java Deletion of object will be handled by garbage collector A special value null can be assigned Always passed by reference Object Example Let Student is a class Student t; // here t is a reference variable t=null;     // Assigning a reference to null  // t=NULL  Error here as  Java  is case sensitive null and NULL are different t = new Student(); // created in heap - Alias name can created for example Student y=t; // here y and t referring to same object in heap Parameter Passing  Primitives by value  Objects by reference Object as parameter  parameter passing by reference Example 1 class Car{ String make; String getMake() { return make;} void setMake(String m){make=m;} } class ChangeCarMake{ ...