Please select a subject first
Advertisements
Advertisements
Give the output of the following String class method:
"COMMENCEMENT".lastIndexOf('M')Concept: String Functions
Give the output of the following String class method:
"devote". compareTo("DEVOTE")Concept: String Functions
Define a class to accept a String and print the number of digits, alphabets and special characters in the string.
| Example: | S = "KAPILDEV@83" |
| Output: | Number of digits - 2 ' Number of Alphabets - 8 Number of Special characters - 1 |
Concept: String Functions
int x = 98; char ch = (char)x; what is the value in ch?
Concept: String Functions
The output of the statement "CONCENTRATION" indexOf('T') is ______.
Concept: String Functions
The output of the statement "talent". compareTo("genius") is ______.
Concept: String Functions
Evaluate the expression when x is 4:
x + = x + + * + + x %2; Concept: Types of Operators
The following code to compare two strings is compiled, the following syntax error was displayed - incompatible types - int cannot be converted to boolean.
Identify the statement which has the error and write the correct statement. Give the output of the program segment.
void calculate()
{
String a="KING",b="KINGDOM";
boolean x=a.compareTo(b);
system.out.println(x);
}Concept: String Functions
Consider the array given below:
char ch[]={'A','E','I','O','U'};
Write the output of the following statements:
System.out.println(ch[0]*2);;Concept: String Functions
Write the output of the following String methods:
String x="Galaxy",y="Games";
(a) System.out.println(x.charAt(0)==y.charAt(0));
(b) System.out.println(x.compareTo(y));Concept: String Functions
State a difference between call by value and call by reference.
Concept: Ways of passing values to a function
Give the output of the following:
Math.sqrt(Math.max(9, 16))
Concept: Invoking a Method
What are the two ways of invoking functions?
Concept: Side Effects of Call by Reference
Differentiate between formal parameter and actual parameter.
Concept: Side Effects of Call by Reference
How are private members of a class different from public members?
Concept: Side Effects of Call by Reference
Design n class to overload a function SumSeriesO as follows:
(i)
void SumSeries(int n, double x) – with one integer argument and one double argument to find and display the sum of the series given below:
`"s" = "x"/1 - "x"/2 + "x"/3 - "x"/4 + "x"/5`...... ...... ...... to n terms
(ii)
void SumSeries() – To find and display the sum of the following series:
s = 1 + (1 x 2) + (1 x 2 x 3) + ….. + (1 x 2 x 3 x 4 x 20)
Concept: Function Overloading
Write a menu-driven program to display the pattern as per the user’s choice.

For an incorrect option, an appropriate error message should be displayed.
Concept: Side Effects of Call by Reference
Write a method prototype name check() which takes an integer argument and returns a char:
Concept: Introduction of User - Defined Method
The number of values that a method can return is ______.
Concept: Introduction of User - Defined Method
A method which does not modify the value of variables is termed as ______.
Concept: Introduction of User - Defined Method
