andObject2->max_speed=180miles/hr, model_name="Superfast go", car_name = "BMW",etc.
Constructor
The constructor is a self-executable block where the constructor doesn't need to explicitly define for the functioning calls.
e.g.
public class Month {
public Month() {
// Default Constructor is calling on creating an object of that class.
}
public Month(String month_name) { // Parametrized Constructor
// This constructor has one parameter, month_name.
System.out.println("Month Name = "+month_name);
...
public static void main(StXXXX args[])
{
XXXXX XXX=new Month(); // calling default XXXXXXXXXXX by default
Month XXXX=new XXXXX("March"); // calling XXXXXXXXXXXX constructor
Default XXXXXXXXXXX XX the first method XXXX is executed in XXX XXXXX if it XX defined and if you XXXXXX any XXXXXXXXX in XXX constructor then it is XXXXXX the XXXXXXXXXXXXX XXXXXXXXXXX.
XXXX XXXXXXXXXXX
X XXXX XXXXXXXXXXX in a Java class is a XXXXXXXXXXX XXXXXXXXXXX an XXXXXX using another object of XXX same Java XXXXX.
XXXX's XXXXXXX when we want XX XXXX a complex object XXXX XXX XXXXXXX fields, or XXXX XX XXXX to make a deep XXXX XX an existing XXXXXX.
XXXXXX XXXXX Month { private XXX id; XXXXXXX String XXXXXXXXXX; public Month(XXXXX XXXXX) { XXXX.id = month.id; this.month_name = XXXXX.name; } }
XXXX, XX copy XXX the XXXXX XXXXXX XX XXXXXXXX.
XXXX (XXXXXXXXXXX)
XXXXXXXXXXX XXXXX XXX list named XXXXXXXX. XX XXX go you define several XXXXXXXXX in a XXX XXXXXXXXX. XX XX created XX keyword using "enum" and values are enclosed in XXX {}.
e.g.enum XXXXXXXX{Sunday, Monday, Tuesday, XXXXXXXXX, Thrusday, Friday,Saturday}
class Month
public XXXXXX void main(String XXXX[])
WeekDays wk; // XXXXXX object...
XX=XXXXXXXX.XXXXXX; //XXXXXX XXXXXXXX XX XXXX here...
XXXXXX.out.println("Today is "+wk); // print the value XX constant...
} }
XXXXX and XXXXXXXXX
XXX XXXXX XX XXXX XX represent the XXXX XXXX XX data or XXXXX has same XXXXXX.
e.g.XXXXXX[] months = {"XXXXX","April","May","June"};
XXX (XXXXXX i: months) {
System.out.println(i);
Array XXXX XX a XXXXXXXXXX XXXXXXXX present in XXXX package. XXX only XXXXXXXXXX XXXXXXX XXXXX XXX XXXXXXXXX is XXXXXXXXX is XXXXXXXXX and XXX XXXXX XX XX fixed size.
XXXXXX java.XXXX.XXXXXXXXX;
public XXXXX XXXXX { public static void XXXX(XXXXXX[] XXXX) { XXXXXXXXX&XX;String&XX; XXXXXXXXXX = XXX XXXXXXXXX&XX;String>(); month_name.add("XXXXXXXXX"); XXXXXXXXXX.add("XXXXXXX"); XXXXXXXXXX.add("November"); XXXXXXXXXX.add("XXXXXXXX"); System.out.println(XXXXXXXXXX); } }
Function Calling
Function calling XX XXXX XX the XXXXXX XXX callee.
XXXX, XXXXXX XX the XXXXXXXXX that calls XXX XXXXXXXXX and called which function is XX be call.
XXX XXXXXXX:-
public void XXXX(XXXXXX name[]) //XXXXXX
System.out.XXXXXXX("I am "+XXXX);
XXXXXX static XXXX XXXX(XXXXXX XXXX[])
XXXX("Aashish"); //caller
Here is XXXX donemethod XXXXXXXXXXX and XXXXXXXXXXXXX-
class XXXXXXXXXXXXXXXXXX //define class XXXXXXXXXXXXXXXXXX
XXXXXX void XXXX(XXXXXX XXXXX) //callee1
XXXXXX.out.println(XXXXX);
public XXXX XXXX(XXXXXX XXXXX, int id) //XXXXXXX
XXXXXX.out.println(XXXXX+ " - "+id);
XXXXX XXXXXX
public static XXXX XXXX(XXXXXX XXXX[])
XXXXXXXXXXXXXXXXXX XXX = XXX XXXXXXXXXXXXXXXXXX();
XXX.XXXX('February'); // XXXXXXX
obj.XXXX('October',10); // caller2
XXXX, XXXX the same name XX a function declared XXX XX calling XXX function XXXXX XXXXXXXXXXXXX changes XX XXXXXX function overloading. XXX XXXXXXXX overload other XXXXXXXX XXXX same name, XX differentiate between two XXXXXXXXX in this scenario, we XXXXXX looking for XXXXXXXXX XXXXXX into the XXXXXXX function.
class XXXXX{ // Parent Class
enum Monthname={"February","XXXXX","April"}
//XXXXXXXXXX XXXXXX
XXXXXX void getName(int id)
XXXXXXXXX mn;
for(XXX i=X;i&XX;XX.length;i++)
if(mn.id == id)
XXXXXX.out.println(XX.month);
class XXXXXXX extends XXXXX{ // Child XXXXX
//Overriding method
XXXXXX XXXX getName(XXX id)
for(int i=0;i<mn.length;i++)
XX(mn.id == id)
System.out.XXXXXXX("XXXX XX XXX month XX "+XX.month +" and id is " + mn.id);
XXXXXX static XXXX main( XXXXXX XXXX[]) {
XXXXXXX obj = XXX XXXXXXX();
//XXXX XXXX call the XXXXX XXXXX XXXXXXX of eat()
obj.getName(X);
Overriding XXXXXX XX behaving similarly to overloading XXX XXXXXXXXXX XXXXX XXXX the same XXXX XXX the XXXX number of XXXXXXXXXX XXXXXXXXXX.
Overriding XXXXXX occur XXXXXXX XXX or more XXXXXXX which is XXXXXXXXX XX XXXX XXXXX where child XXXXX have XXX XXXX name of XXX function with XXX same XXXXXX of the parameter XX XXX parent class XXX then child class XXXXXX it's own function not it's parent function. is called method overriding. XX access the XXXXXX function we XXX super() method or this() XXXXXX XX XXXXXXXXX XXX XXXXXX's method.
XXXXXXXXXX for Assignment XXXXXXX
Welcome XX SIM Set Theory lesson
X: Properties XX set X: XXXXX XXXXXXX X: XXXXXXXXXXXX example X. XXXXXX example 4. XXXXXXXXXX XXXXXXX X. Complement XXXXXXX 6. XXXX XXXXXXXX example X.Quiz
XXXX for XXXX XXXXXXX :-
XXXXXX java.XXXX.XXXXXXX;
class Month{
XXXX Month_name {XXXXXXX,XXXXXXXX,March,April,May,XXXX,XXXX,XXXXXX,September,XXXXXXX,November,XXXXXXXX};
ArrayList&XX;XXXXXX> a = XXX ArrayList<XXXXXX&XX;; // creating ArrayList XXX XXX A... a.add("XXX"); a.add("XXX"); a.add("May); a.add("Oct"); a.add("Sep"); a.add("XXX"); a.add("XXX");
XXXXXXXXX<String&XX; b=XXX ArrayList&XX;String&XX;; // XXXXXXXX XXXXXXXXX XXX set X... b.add("XXX"); b.add("XXX"); b.add("Jul");
XXXXXX Month() { // XXXXXXXX XXXXXXXXXXX }
XXXXXX XXXXXX void XXXXXXXXXXXXXXXXX() { // write XXXX own code here... }
public XXXXXX void Union_example() { // write XXXX own code XXXX... }
XXXXXX static void XXXXXXXXXXXXXXXXXXXX() { // write XXXX own code here... }
public XXXXXX XXXX XXXXXXXXXXXXXX() { // XXXXX your own XXXX XXXX... }
public XXXXXX XXXX XXXXXXXXXXXXXXXXXX() { // write XXXX own code XXXX... }
public static XXXX XXXXXXXXXXXXXXXXXX() { // XXXXX your own XXXX here... }
XXXXXX static void XXXXXXXXXXXXXXXXXXXXX() { // write XXXX own XXXX here... }
XXXXXX XXXXXX XXXX XXXX() { // write XXXX own code XXXX... }
XXXXXX XXXXXX void main(XXXXXX args[]){ XXXXXXX in = XXX XXXXXXX(System.in); XXXXXX.out.println("Welcome XX XXX XXX XXXXXX lesson\n X: XXXXXXXXXX XX set\n 1: Union example\n X: XXXXXXXXXXXX example\n X. Subset example\n X. XXXXXXXXXX example\n X. Complement XXXXXXX\n X. XXXX XXXXXXXX example\n X.XXXX\n"); XXXXXX.out.XXXXX("XXXX option: "); int XXXXXX=in.XXXXXXX();
switch(ch) { case X : Properties_of_set(); XXXXX; case X: Union_example(); XXXXX; XXXX X: Intersection_example(); XXXXX; case X: XXXXXXXXXXXXXX(); break; XXXX X: Difference_example(); XXXXX; case X: XXXXXXXXXXXXXXXXXX(); XXXXX; XXXX X: Sets_equality_example(); XXXXX; XXXX X: Quit(); XXXXX; default: XXXXXX.out.XXXXXXX("Invalid Choice"); XXXXX; } } }