DUET PG Score Card 2021
NHAI Recruitment 2021
Bihar Board 12th Dummy Admit Card 2022
RBI Assistant Notification 2021
Jee Advanced 2021 Result
NIACL Assistant Recruitment 2021
SBI PO Online Form 2021

Write a class ElementCheck with a public method checkFirstOrLast that takes two parameters one is arr of type int[] and second one is arg of type int and returns true

Write a class ElementCheck with a public method checkFirstOrLast that takes two parameters one is arr of type int[] and second one is arg of type int and returns true if the arg is first or last element in the arr else returns false. The return type of checkFirstOrLast is boolean.

Assumption:

  1. arr is never null

Here is an example:

Enter no of elements in the array: 4
Enter elements in the array seperated by space:1 2 3 6
Enter the search element:6
true

Note: Please don’t change the package name.

Solution:

package q11047;
public class ReversePrint { 
    
    /** * write a logic to find the array of elements in reverse order.
    * 
    *
    * 
    @return the reverseArray */
    
	public int[] reversePrint(int[] arr) { 
	    //Wrtie code here 
	    
	    int[] ReversePrint = new int[arr.length];
	    
	    for(int i = 0; i<arr.length; i++){ 
	        
	        ReversePrint[i] = arr[arr.length-1-i]; 
	    } 
	        return ReversePrint;
	        }
}

Candidates having any kind of query so he/she can ask in our comment section. Our Panel will b reverting back as soon as possible. Thank You. For more details visit our website (https://speedjobalert.com/)

Leave a Comment