Answer:
import java.util.Arrays;
public class num2 {
public static void main(String[] args) {
int []intArray = new int[100];
for(int i=0; i<intArray.length; i++){
intArray[i] = i+1;
}
System.out.println(Arrays.toString(intArray));
}
}
Explanation:
Firstly create an array of size 100 with this statement
int []intArray = new int[100];
Using a for loop add elements into the array starting at i=0+1 (to acheive an asceending order) since i will run from 0-99.
see the attached code and output
Explanation:
Age = 23.
To convert a base 10 number to hexadecimal number we have to repeatedly divide the decimal number by 16 until it becomes zero and store the remainder in the reverse direction of obtaining them.
23/16=1 remainder = 5
1/16=0 remainder = 1
Now writing the remainders in reverse direction that is 15.
My age in hexadecimal number is (15)₁₆.
Answer:
(s.charAt(0) != s.charAt(s.length()-1))
Explanation:
public class Palindrome
{
public static void main(String[] args) {
System.out.println(isPalindrome("car"));
System.out.println(isPalindrome("carac"));
}
public static boolean isPalindrome(String s) {
if (s.length() <= 1)
return true;
else if (s.charAt(0) != s.charAt(s.length()-1))
return false;
else
return isPalindrome(s.substring(1, s.length() - 1));
}
}
You may see the whole code above with two test scenarios.
The part that needs to be filled is the base case that if the character at position 0 is not equal to the character at the last position in the string, that means the string is not a palindrome. (If this condition meets, it checks for the second and the one before the last position, and keeps checking)
True
cat /dev/null > fileName
------------------------------------
Answer: M and E
Explanation: Hope this helps