Please select a subject first
Advertisements
Advertisements
Name a string function which removes the blank spaces provided in the prefix and suffix of a string.
Concept: undefined >> undefined
Give the output of the following string functions:
- “ACHIEVEMENT”.replace(E’, ‘A’)
- “DEDICATE”.compareTo(“DEVOTE”)
Concept: undefined >> undefined
Advertisements
Using the switch statement, write a menu-driven program for the following:
(i) To print Floyd’s triangle [Given below]
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
(ii) To display the following pattern:
I
I C
I C S
I C S E
For an incorrect option, an appropriate error message should be displayed.
Concept: undefined >> undefined
Rewrite the following using ternary operator :
if (bill > 10000)
discount = bill * 10.0 / 100;
else
discount = bill * 5.0 / 100;Concept: undefined >> undefined
Give the output of the following program segment and also mention how many times the loop is executed :
int i;
for (i = 5; i > 10; i++)
System.out.println(i);
System.out.println(i * 4);Concept: undefined >> undefined
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: undefined >> undefined
Write two separate programs to generate the following patterns using iteration (loop) statement:
(a)
Concept: undefined >> undefined
Write a program to input a number and check and print whether it is a Pronic number or not. (Pronic number is the number which is the product of two consecutive integers).
Examples: 12 = 3 × 4
20 = 4 × 5
42 = 6 × 7
Concept: undefined >> undefined
Write two separate programs to generate the following patterns using iteration (loop) statement:
(b)

Concept: undefined >> undefined
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: undefined >> undefined
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: undefined >> undefined
Write a program to input and store roll numbers, names and marks in 3 subjects of n number students in five single dimensional array and display the remark based on average marks as given below : (The maximum marks in the subject are 100).
Average marks = `"Total marks"/3`
| Average marks | Remark |
| 85 - 100 | Excellent |
| 75 - 84 | Distinction |
| 60 - 74 | First-class |
| 40 - 59 | Pass |
| Less than 40 | Poor |
Concept: undefined >> undefined
Write a program to input twenty names in an array. Arrange these names in descending order of alphabets, using the bubble sort technique.
Concept: undefined >> undefined
Which of the following are valid comments ?
(i) /* comment */
(ii) /* comment
(iii) / / comment
(iv) */ comment */
Concept: undefined >> undefined
Name the primitive data type in Java that is:
A 64-bit integer and is used when you need a range of values wider than those provided by int.
Concept: undefined >> undefined
Name the primitive data type in Java that is :
A single 16-bit Unicode character whose default value is ‘\u0000’.
Concept: undefined >> undefined
Operators with higher precedence are evaluated before operators with relatively lower precedence. Arrange the operators given below in order of higher precedence to lower precedence.
- &&
- %
- >=
- ++
Concept: undefined >> undefined
Give two differences between the switch statement and the If-else statement.
Concept: undefined >> undefined
What is an infinite loop ? Write an infinite loop statement.
Concept: undefined >> undefined
when is a constructor invoked?
Concept: undefined >> undefined
