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(String args[])
{
Month mon=new Month(); // XXXXXXX XXXXXXX XXXXXXXXXXX by XXXXXXX
Month XXXX=new XXXXX("XXXXX"); // calling parametrized constructor
XXXXXXX XXXXXXXXXXX is the first XXXXXX XXXX XX XXXXXXXX in the class XX it XX XXXXXXX and XX you define any XXXXXXXXX in the XXXXXXXXXXX XXXX it is XXXXXX XXX parameterized constructor.
Copy XXXXXXXXXXX
X XXXX XXXXXXXXXXX in a XXXX XXXXX is a constructor XXXXcreates an XXXXXX using XXXXXXX XXXXXX XX XXX same XXXX class.
That's helpful XXXX XX XXXX XX copy a XXXXXXX XXXXXX that XXX XXXXXXX XXXXXX, or when we want XX XXXX a deep copy of an XXXXXXXX object.
public class Month { XXXXXXX int id; XXXXXXX String month_name; public Month(Month month) { XXXX.id = XXXXX.id; this.XXXXXXXXXX = month.name; } }
XXXX, we XXXX all the input XXXXXX XX XXXXXXXX.
XXXX (XXXXXXXXXXX)
Enumeration means the XXXX XXXXX XXXXXXXX. XX XXX go you define XXXXXXX XXXXXXXXX in a XXX statement. It XX created XX keyword XXXXX "enum" and values are XXXXXXXX in XXX {}.
e.g.enum XXXXXXXX{Sunday, XXXXXX, Tuesday, Wednesday, XXXXXXXX, Friday,XXXXXXXX}
class Month
public static void main(String XXXX[])
XXXXXXXX XX; // making XXXXXX...
wk=XXXXXXXX.XXXXXX; //XXXXXX constant by enum XXXX...
System.out.println("XXXXX XX "+XX); // print XXX XXXXX XX constant...
} }
XXXXX XXX ArrayList
XXX array is XXXX XX represent XXX same type XX XXXX or which has same XXXXXX.
e.g.XXXXXX[] XXXXXX = {"XXXXX","XXXXX","May","XXXX"};
XXX (String i: XXXXXX) {
XXXXXX.out.println(i);
Array XXXX is a XXXXXXXXXX XXXXXXXX present in util XXXXXXX. The only difference between Array and XXXXXXXXX is XXXXXXXXX is resizable XXX the array XX of fixed size.
import java.XXXX.XXXXXXXXX;
XXXXXX class Month { public XXXXXX void XXXX(String[] XXXX) { XXXXXXXXX<XXXXXX> month_name = new ArrayList&XX;XXXXXX&XX;(); XXXXXXXXXX.add("September"); month_name.add("October"); XXXXXXXXXX.add("November"); month_name.add("XXXXXXXX"); XXXXXX.out.XXXXXXX(XXXXXXXXXX); } }
XXXXXXXX XXXXXXX
XXXXXXXX XXXXXXX is done XX the XXXXXX XXX callee.
Here, XXXXXX is XXX XXXXXXXXX XXXX calls XXX functions XXX XXXXXX XXXXX function is XX be call.
XXX XXXXXXX:-
XXXXXX void XXXX(String name[]) //callee
XXXXXX.out.XXXXXXX("I am "+name);
public XXXXXX XXXX XXXX(String XXXX[])
name("Aashish"); //caller
XXXX is XXXX doneXXXXXX overloading XXX XXXXXXXXXXXXX-
class DisplayOverloading //define class XXXXXXXXXXXXXXXXXX
public XXXX disp(String month) //XXXXXXX
System.out.XXXXXXX(XXXXX);
public XXXX disp(XXXXXX XXXXX, XXX id) //XXXXXXX
System.out.XXXXXXX(XXXXX+ " - "+id);
XXXXX Sample
public XXXXXX XXXX XXXX(XXXXXX XXXX[])
DisplayOverloading XXX = new XXXXXXXXXXXXXXXXXX();
obj.disp('February'); // caller1
obj.disp('October',10); // caller2
XXXX, XXXX XXX XXXX XXXX XX a XXXXXXXX XXXXXXXX but on calling XXX function their functionality changes XX called XXXXXXXX XXXXXXXXXXX. XXX XXXXXXXX overload other function XXXX same name, XX differentiate between XXX functions in XXXX scenario, XX always XXXXXXX XXX parameter XXXXXX into the XXXXXXX XXXXXXXX.
class Month{ // Parent Class
enum Monthname={"XXXXXXXX","March","April"}
//Overridden method
public XXXX XXXXXXX(XXX id)
Monthname mn;
for(int i=0;i&XX;XX.XXXXXX;i++)
if(XX.id == id)
XXXXXX.out.XXXXXXX(mn.month);
XXXXX MyMonth XXXXXXX XXXXX{ // XXXXX Class
//Overriding XXXXXX
XXXXXX void XXXXXXX(int id)
XXXXXXXXX XX;
for(int i=0;i&XX;mn.length;i++)
if(mn.id == id)
System.out.XXXXXXX("Name XX XXX month is "+XX.month +" XXX id XX " + XX.id);
XXXXXX XXXXXX XXXX XXXX( XXXXXX args[]) {
XXXXXXX XXX = XXX XXXXXXX();
//XXXX XXXX call XXX XXXXX class XXXXXXX of eat()
XXX.XXXXXXX(2);
Overriding XXXXXX XX XXXXXXXX similarly XX overloading but XXXXXXXXXX XXXXX with the XXXX XXXX and the same XXXXXX XX parameters initialize.
XXXXXXXXXX mainly XXXXX between two or more XXXXXXX XXXXX XX inherited XX each other where XXXXX XXXXX XXXX XXX XXXX XXXX XX the XXXXXXXX XXXX XXX XXXX number of the parameter XX XXX parent XXXXX has then XXXXX XXXXX XXXXXX it's own XXXXXXXX XXX it's XXXXXX XXXXXXXX. XX called XXXXXX overriding. To access XXX XXXXXX XXXXXXXX XX XXX XXXXX() XXXXXX or this() method to XXXXXXXXX the parent's method.
XXXXXXXXXX for XXXXXXXXXX Snippet
XXXXXXX to SIM XXX XXXXXX lesson
X: XXXXXXXXXX XX XXX 1: Union XXXXXXX 2: Intersection XXXXXXX 3. Subset XXXXXXX X. XXXXXXXXXX example X. Complement example 6. Sets equality example 9.Quiz
Code XXX XXXX XXXXXXX :-
import XXXX.util.Scanner;
class XXXXX{
XXXX XXXXXXXXXX {January,February,March,XXXXX,XXX,XXXX,XXXX,XXXXXX,XXXXXXXXX,XXXXXXX,XXXXXXXX,December};
ArrayList<XXXXXX&XX; a = XXX ArrayList<XXXXXX&XX;; // creating XXXXXXXXX XXX XXX A... a.add("Jan"); a.add("XXX"); a.add("May); a.add("Oct"); a.add("XXX"); a.add("Dec"); a.add("XXX");
XXXXXXXXX&XX;XXXXXX&XX; b=XXX ArrayList<XXXXXX&XX;; // creating XXXXXXXXX XXX set B... b.add("Nov"); b.add("Apr"); b.add("XXX");
public XXXXX() { // creating constructor }
public static void XXXXXXXXXXXXXXXXX() { // XXXXX XXXX own code here... }
XXXXXX XXXXXX void Union_example() { // XXXXX your own XXXX here... }
public static void XXXXXXXXXXXXXXXXXXXX() { // write XXXX own XXXX XXXX... }
XXXXXX XXXXXX void XXXXXXXXXXXXXX() { // write your own XXXX here... }
XXXXXX XXXXXX void Difference_example() { // write your own XXXX XXXX... }
XXXXXX XXXXXX XXXX XXXXXXXXXXXXXXXXXX() { // XXXXX XXXX own code XXXX... }
XXXXXX XXXXXX void XXXXXXXXXXXXXXXXXXXXX() { // XXXXX XXXX own code XXXX... }
public XXXXXX void XXXX() { // write your own code here... }
public static void XXXX(XXXXXX XXXX[]){ XXXXXXX in = new Scanner(XXXXXX.in); System.out.XXXXXXX("XXXXXXX XX XXX Set XXXXXX lesson\n X: XXXXXXXXXX XX XXX\n X: XXXXX example\n X: XXXXXXXXXXXX example\n 3. Subset XXXXXXX\n 4. Difference XXXXXXX\n 5. XXXXXXXXXX example\n X. XXXX equality example\n 9.XXXX\n"); System.out.print("Your XXXXXX: "); XXX choice=in.XXXXXXX();
switch(XX) { case X : XXXXXXXXXXXXXXXXX(); break; XXXX 1: XXXXXXXXXXXXX(); break; XXXX X: XXXXXXXXXXXXXXXXXXXX(); XXXXX; case 3: Subset_example(); XXXXX; case 4: XXXXXXXXXXXXXXXXXX(); XXXXX; case X: XXXXXXXXXXXXXXXXXX(); XXXXX; case 6: Sets_equality_example(); XXXXX; XXXX X: Quit(); break; default: XXXXXX.out.println("XXXXXXX XXXXXX"); break; } } }