Computer Applications
Write Java statements for the following:
(a) To assign the cube root of -343 to a variable with the appropriate datatype.
(b) To assign the position of the last occurrence of @ in the String s with the appropriate datatype.
Java Math Lib Methods
5 Likes
Answer
(a) double cubeRoot = Math.cbrt(-343);
(b) int pos = s.lastIndexOf('@');
Answered By
3 Likes
Related Questions
Kamal wants to display only the alphabets stored in a character array. While compiling the code, an error was displayed. Check for the statement with the error and write the correct statement.
char arr[]={'4', '&', 'a', 'w', 'd'}; int i; for(i=0;i<arr.length;i++) { if(Character.isLetter(arr)) System.out.println(arr); }Name the type of type casting in the given statements:
(a) double m = 'b';
(b) char ch = (char)68;Mention the output of this code snippet:
int lives = 5; System.out.println(lives--); System.out.println(lives);Convert the following for loop segment to an exit-controlled loop.
for(k = 10;k >= -1;k--) System.out.println(k*2); System.out.println(k*4);