Please select a subject first
Advertisements
Advertisements
Write one difference between / and % operator.
Concept: Introduction of Operators in Java
String x[] = {“SAMSUNG”, “NOKIA”, “SONY”, “MICROMAX”, “BLACKBERRY”};
Give the output of the following statements:
- System.out.println(x[1]);
- System.out.println(x[3].length());
Concept: StringBuffer Functions
Write a Java expression for the following :
ax5 + bx3 + c
Concept: Introduction of Operators in Java
Write the output for the following :
String s= “Today is Test”;
System.out.println(s.indexOf(‘T’)); System.out.println(s.substring(0, 7) + ” ” + “Holiday”);
Concept: StringBuffer Functions
State the difference between == operator and equals () method.
Concept: Introduction of Operators in Java
Using switch statement, write a menu-driven program for the following :
(i) To find and display the sum of the series given below :
S = x1 -x2 + x2 – x4 + x5 – x20
(where x = 2)
(ii) To display the following series :
1 11 111 1111 11111
For an incorrect option, an appropriate error message should be displayed.
Concept: Introduction of Operators in Java
Give the output of the following string functions:
- "MISSISSIPPI".indexOf('S') + "MISSISSIPPI".lastIndexOf('I')
- "CABLE".compareTo("CADET")
Concept: Concept of String Class
Write down java expression for:
`"T" = sqrt("A"^2 + "B"^2 + "C"^2)`
Concept: Introduction of Operators in Java
Rewrite the following using ternary operator:
if (x%2 == o)
System.out.print(“EVEN”);
else
System.out.print(“ODD”);
Concept: Introduction of Operators in Java
Write the return data type of the following function:
endsWith( )
Concept: String Functions
Write a Java expression for the following :
`sqrt(3"x"+"x"^2)/"a+b"`
Concept: Introduction of Operators in Java
What is the function of catch block in exception handling? Where does it appear in a program?
Concept: StringBuffer Functions
State the output when the following program segment is executed:
String a = "Smartphone", b = "Graphic Art";
String h = a.substring(2, 5);
String k = b.substring(S).toUpperCase();
System.out.println(h);
System.out.println(k.equalsignoreCase(h)); Concept: StringBuffer Functions
Write the output for the following :
System.out.printIn(“Incredible” + “\n” + “world”);
Concept: StringBuffer Functions
Give the output of the following string functions:
- “ACHIEVEMENT”.replace(E’, ‘A’)
- “DEDICATE”.compareTo(“DEVOTE”)
Concept: Concept of String Class
If int y = 10 then find int z = (++y * (y++ +5));
Concept: StringBuffer Functions
Rewrite the following using ternary operator :
if (bill > 10000)
discount = bill * 10.0 / 100;
else
discount = bill * 5.0 / 100;Concept: Introduction of Operators in Java
Design a class Railway Ticket with following description:
Instance variables/data members:
String name: To store the name of the customer
String coach: To store the type of coach customer wants to travel
long mob no: To store customer’s mobile number
int amt: To store a basic amount of ticket
int total amt: To store the amount to be paid after updating the original amount
Member methods
void accept (): To take input for a name, coach, mobile number and amount
void update (): To update the amount as per the coach selected
(extra amount to be added in the amount as follows)
| Type of Coaches | Amount |
| First_ AC | 700 |
| Second_AC | 500 |
| Third _AC | 250 |
| sleeper | None |
void display(): To display all details of a customer such as a name, coach, total amount and mobile number.
Write a main method to create an object of the class and call the above member methods.
Concept: Concept of String Class
Special words are those words that start and end with the same letter.
Examples:
EXISTENCE
COMIC
WINDOW
Palindrome words are those words which read the same from left to right and vice versa
Examples:
MALAYALAM
MADAM
LEVEL
ROTATOR
CIVIC
All palindromes are special words, but all special words are not palindromes. Write a program to accept a word check and print Whether the word is a palindrome or only a special word.
Concept: Concept of String Class
Write a program in Java to accept a string in lower case and change the first letter of every word to upper case. Display the new string.
Sample input: we are in a cyber world
Sample output: We Are In Cyber World
Concept: Introduction of Operators in Java
