Computer Applications
Name the following:
(a) The return data type of the method equals().
(b) The String method which has no parameter and returns a String.
Java String Handling
3 Likes
Answer
(a) boolean
(b) toUpperCase()
Answered By
1 Like
Related Questions
int X[][] = {{4, 5}, {7, 2}, {19, 4}, {7, 4}};
Write the index of the maximum element and the index of the minimum element of the array.
The following program segment swaps the first element and the second element of the given array without using the third variable, fill in the blanks with appropriate java statements:
void swap() { int x[] = {4, 8, 19, 24, 15}; (1) ............... ; (2) ............... ; x[0] = x[0] / x[1]; System.out.println(x[0] + " " + x[1]); }Define a class named StepTracker with the following specifications:
Member Variables:
- String name – stores the user's name
- int sw – stores the total number of steps walked by the user.
- double cb – stores the estimated calories burned by the user.
- double km – stores the estimated distance walked in kilometers.
Member Methods:
- void accept() – to input the name and the steps walked using Scanner class methods only.
- void calculate() – calculates calories burned and distance in km based on steps walked using the following estimation table:
Metric Calculation Formula Calories Burned steps walked x 0.04 (e.g., 1 step burns 0.04 calories) Distance (Km) steps walked / 1300 (e.g., 1300 steps is approx. 1 km) - void display() – Display the calories burned, distance in km and the user's name.
Write a main method to create an object of the class and invoke the methods.
Write a program to accept the designations of 100 employees in a single dimensional array. Accept the designation from the user and print the total number of employees with the designation given by the user as input.
Example:
Trainee Manager Chef Manager Director Manager Input: Manager Output: 3