Class :
class <class_name>{
data members;
methods;
}
Object :
<Class name> object = new <Class name>();
new <Class name>();
Example :
Public class Printer {
int pageNumbers;
String documentName;
public boolean doPrint(String documentToPrint ) {
//Print the documents and return the boolean result
return true;
}
}
Public Class System {
String documentToPrint = "D:/payslip.doc";
public static void main() {
Printer printer = new Printer();
boolean result = printer .doPrint(documentToPrint);
if(result) {
System.out.println("Document printed successfully!..");
}else {
System.out.println("Document printed successfully!..");
}
}
}
No comments:
Post a Comment