Please select a subject first
Advertisements
Advertisements
Give the output of the following method:
public static void main (String [] args)
{
int a = 5;
a++;
System.out.println(a);
a -= (a--) − (--a);
System.out.println(a);
}
Concept: StringBuffer Functions
State the value of characteristic and mantissa when the following code is executed:
String s = “4.3756”;
int n = s.indexOf(‘.’);
int characteristic=Integer.parseInt (s.substring (0,n));
int mantissa=Integer.valueOf(s.substring(n+1));
Concept: StringBuffer Functions
Define a class named movieMagic with the following description:
Instance variables/data members:
int year — to store the year of release of a movie.
String title — to-store the title of the movie
float rating — to store the popularity rating of the movie
(minimum rating=0.0 and maximum rating=5.0)
Member methods:
(i) movieMagic() Default constructor to initialize numeric data members to 0 and String data member to “ ”.
(ii) void accept() To input and store year, title and rating.
(iii) void display() To display the title of a movie and a message based on the rating as per the table below.
| Rating | Message to be displayed |
| 0.0 to 2.0 | Flop |
| 2.1 to 3.4 | Semi-hit |
| 3.5 to 4.5 | Hit |
| 4.6 to 5.0 | Super Hit |
Write a main method to create an object of the class and call the above member methods.
Concept: StringBuffer Functions
Give the output of the following string methods.
"MISSISSIPPI".indexOf('S') + "MISSISSIPPI".lastIndexOf('I')
Concept: String Functions
Define a class to accept two strings, convert them into uppercase, check and display whether two strings are equal or not, if the two strings are not equal, print the string with the highest length or print the message both the strings are of equal length.
Concept: String Functions
Define a class to accept a string, convert it into lowercase and check whether the string is a palindrome or not.
A palindrome is a word that reads the same backward as forward.
Example:
madam, racecar etc.
Concept: String Functions
A Identify the type of operator &&:
Concept: Types of Operators
The String class method to join two strings is ______.
Concept: String Functions
The output of the function "COMPOSITION". substring(3, 6):
Concept: String Functions
The code obtained after compilation is known as ______.
Concept: Introduction of Operators in Java
Write the Java expression for (a + b)x.
Concept: Introduction of Operators in Java
Evaluate the expression when the value of x = 4;
x* = - - x + x + + + x
Concept: Introduction of Operators in Java
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
