ITEC 2610 Final: JAVA BASICS

328 views6 pages

Document Summary

An object is an instance of a class. >> local variables: defined inside methods, constructors or blocks. Variables are destroyed when the method is complete. >>instance variables: within a class but outside any method. >>class variables: declared within a class, outside any method, with the static keyboard. Class: can be defined as a template/blueprint that describes the behavior/ state that the object of its type supports. >>>constructors have the same name as the class. >>>a constructor is invoked when a new object is created. It is in methods where the logics are written, data is manipulated and all the actions are executed. >>declaration: a variable declaration with a variable name and with an object type. >>instantiation: the new keyword is used to create the object. >>initialization: the new keyword is followed by a call to a constructor. Example: public class puppy { public static void main(string [] args) { //the following is creating a new object mypuppy.