Seminar 1
Seminar 1
Seminar 1
Instance Variables: Instance variables are non-static variables and are declared in
a class and outside any method.
--> these variables are created when an object of the class is created and
destroyed when the object is destroyed.
Ex:import java.io.*;
class Marks {
// These variables are instance variables.
// These variables are in a class
// and are not inside any function
int engMarks;
int mathsMarks;
int phyMarks;
}
class MarksDemo {
public static void main(String args[])
{
// first object
Marks obj1 = new Marks();
obj1.engMarks = 50;
obj1.mathsMarks = 80;
obj1.phyMarks = 90;
// second object
Marks obj2 = new Marks();
obj2.engMarks = 80;
obj2.mathsMarks = 60;
obj2.phyMarks = 85;
Static variable: static variables are declared using the static keyword within a
class outside any method.
-->need not create an object of that class.
-->To access static variables-->class_name.variable_name;
EX:import java.io.*;
class Emp {
Type Casting:is a method or process that converts a data type into another data
type in both ways manually and automatically.
-->The automatic conversion is done by the compiler and manual conversion performed
by the programmer.
Debugging:
-->it allows you to run a program interactively while watching the source code and
the variables during the execution.
-->A breakpoint in the source code specifies where the execution of the program
should stop during debugging.