Please select a subject first
Advertisements
Advertisements
Consider the following program segment and answer the questions given below:
int x[][]={{2,4,5,6}, {5,7,8,1}, {34,2,10,9}};
- What is the position of 34?
- What is the result of x[2][3] + x[1][2]?
Concept: Double Dimensional Array
Define a class with the following specifications:
Class name: Bank
Member variables:
double p - stores the principal amount
double n - stores the time period in years
double r - stores the rate of interest
double a - stores the amount
member methods:
void accept () - input values for p and n using Scanner class methods only.
void calculate () - calculate the amount based on the following conditions:
| Time in (Year) | Rate % |
| Upto `1/2` | 9 |
| >`1/2` to 1 year | 10 |
| > 1 to 3 year | 11 |
| > 3year | 12 |
`a = p (1+r/100)^n`
void display () - display the details in the given format.
Write the main method to create an object and call the above methods.
Concept: Tokens
Define a class to search for a value input by the user from the list of values given below. If it is found display the message "Search successful", otherwise display the message "Search element not found” using Binary search technique.
5.6, 11.5, 20.8, 43.1, 52.4, 66.6, 78.9, 80.0, 95.5.
Concept: Using array elements
Define a class to accept values into a 4 × 4 array and find and display the sum of each row.
Example:
A[][]={1,2,3,4),{5,6,7,8},{1,3,5,7},{2,5,3,1}}
Output:
sum of row 1=10 (1+2+3+4)
sum of row 2=26 (5+6+7+8)
sum of row 3=16 (1+3+5+7)
sum of row 4=11 (2+5+3+1)
Concept: Double Dimensional Array
Write a difference between unary and binary operator.
Concept: Introduction of Operators in Java
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
