Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you help me please? :/ What static methods arc, how they are declared, and h

ID: 3678614 • Letter: C

Question

Can you help me please? :/

What static methods arc, how they are declared, and how they are called. How to declare and traverse a I -dimensional array using a for loop How to dcclarc and traverse a 2-dimensional array using nested for loops What are the advantages of using an Array List or a Vector instead of an array. Functionality of an ArrayList: inserting at the end. inserting into a specific slot, get from a specific slot, contains (what else is needed?), indexOf(what else is needed?), remove(what else is needed?)

Explanation / Answer

Question 1:

If you apply static keyword with any method, it is known as static method.

    A static method belongs to the class rather than object of a class.
    A static method can be invoked without the need for creating an instance of a class.
    static method can access static data member and can change the value of it.

Static methods in Java can be called without creating an object of class. It can be called by directly refering the class name or object.

Uisng "Static" keyword before any method creates a static method.

Question 2:

Declare a 1-dimensional array:

<DataType> Name[]= new <DataType>[size];

int n[]=new int[10];

Traverse array:

for (int i=0;i<n.length;i++)

System.out.println(a[i]);

Question 3:

Declare a 2-dimensional array:

<DataType>[] Name= new <DataType>[size][size];

int[][] n=new int[3][3];//create 3X3 array

n={{1,2,3},{2,4,5},{4,4,5}}; //initialize array

Traverse array:

for(int i=0;i<a.length;i++){  

for(int j=0;j<a[0].length;j++){

   System.out.print(arr[i][j]+" ");  

}  

System.out.println();

}  

Question 4:

Disadvantages of arrays:

Advantages of arraylist over array:

Differences:

Adnavtages of vector:

The only disadvantage is vector is an object, memory consumption is more.

Question 5:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote