Advertisements
Advertisements
What are the various types of errors in Java?
Concept: Introduction of Operators in Java
Write the output for the following :
String s1 = “phoenix”; String s2 =”island”;
System.out.prindn (s1.substring(0).concat (s2.substring(2)));
System.out.println(s2.toUpperCase( ));
Concept: StringBuffer Functions
String x[ ] = {“Artificial intelligence”, “IOT”, “Machine learning”, “Big data”};
Give the output of the following statements:
(i) System.out.prindn(x[3]);
(ii) System.out.prindn(x.length);
Concept: StringBuffer Functions
Design a class name ShowRoom with the following description :
Instance variables/ Data members :
String name – To store the name of the customer
long mobno – To store the mobile number of the customer
double cost – To store the cost of the items purchased
double dis – To store the discount amount
double amount – To store the amount to be paid after discount
Member methods: –
ShowRoom() – default constructor to initialize data members
void input() – To input customer name, mobile number, cost
void calculate() – To calculate discount on the cost of purchased items, based on following criteria
| Cost | Discount (in percentage) |
| Less than or equal to ₹ 10000 | 5% |
| More than ₹ 10000 and less than or equal to ₹ 20000 | 10% |
| More than ₹ 20000 and less than or equal to ₹ 35000 | 15% |
| More than ₹ 35000 | 20% |
void display() – To display customer name, mobile number, amount to be paid after discount
Write a main method to create an object of the class and call the above member methods.
Concept: Concept of String Class
Write a program to input a sentence and convert it into uppercase and count and display the total number of words starting with a letter ‘A’.
Example:
Sample Input: ADVANCEMENT AND APPLICATION OF INFORMATION TECHNOLOGY ARE EVER CHANGING.
Sample Output: Total number of words starting with letter A’ = 4.
Concept: StringBuffer Functions
A tech number has even number of digits. If the number is split in two equal halves, then the square of sum of these halves is equal to the number itself. Write a program to generate and print all four-digit tech numbers.
Example :
Consider the number 3025
Square of sum of the halves of 3025 = (30+25)2
= (55)2
= 3025 is a tech number.
Concept: StringBuffer Functions
Name the operators listed below are
(i) <
(ii) + +
(iii) &&
(iv) ? :
Concept: Introduction of Operators in Java
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
