Skip to main content

Posts

internet technology

internet technology Describe the difference b/w variable holding primitive value as compared with object reference through program The main difference is that primitive variables hold values, while object variables hold references to values. You can think of an object variable has holding the location of the value, rather than the value itself. This is somewhat similar to the concept of pointers in C and C++. However, it's somewhat more abstract in Java, since you can't actually directly read or manipulate the memory location in an object reference (and, in fact, it may not always be the same). In java, we have the primitives such as int, double, boolean, short, long.... These parts of the language are lengths of bytes. They can only hold a value. But also we have API types such as Integer, Double, Boolean, Short, Long... (note the caps). Objects have: states, values, and behaviors. One 'thing' holds a collection of different types information. The Object ty...

CONSTRUCTOR & KEYWORDS IN JAVA

Java supports a special type of methods, called constructor that enables an object to initialize itself when it is created. Constructors have the same name as the class it-self.   Constructors do not specify a return type, not even void. This is because they return the instance of the class itself. A constructor is automatically called when an object is created. Syntax: Constructor_name([arguments]) {            // body } Constructors are generally of two types. 1.      Non-Parameterized 2.      Parameterized   KEYWORDS IN JAVA We are going to learn few regularly used keywords. 1. new 2. this 3. static 4. super 5. final new: The new keyword dynamically allocates memory for an object. Syntax: claas_name object _name  = new class_name(); EX. Box b1 = new Box(); Box b2 = new Box();  We have already seen so many programs in wh...