Computer Applications
int P[ ] = {12, 14, 16, 18};
int Q[ ] = {20, 22, 24};
Place all elements of P array and Q array in the array R one after the other.
(a) What will be the size of array R[ ] ?
(b) Write index position of first and last element?
Java Arrays
ICSE Sp 2024
51 Likes
Answer
int R[ ] = {12, 14, 16, 18, 20, 22, 24};
(a) Size of array P[ ] = 4
Size of array Q[ ] = 3
Size of array R[ ] = 7 (4 + 3).
(b) Index position of first element is 0.
Index position of last element is 6.
Answered By
34 Likes
Related Questions
Predict the output of the following code snippet:
String a = "20"; String b = "23"; int p = Integer.parseInt(a); int q = Integer.parseInt(b); System.out.print(a + "*" + b);
When there is no explicit initialization, what are the default values set for variables in the following cases?
(a) Integer variable
(b) String variable
Define a class called with the following specifications:
Class name: Eshop
Member variables:
String name: name of the item purchased
double price: Price of the item purchasedMember methods:
void accept(): Accept the name and the price of the item using the methods of Scanner class.
void calculate(): To calculate the net amount to be paid by a customer, based on the following criteria:Price Discount 1000 – 25000 5.0% 25001 – 57000 7.5 % 57001 – 100000 10.0% More than 100000 15.0 % void display(): To display the name of the item and the net amount to be paid.
Write the main method to create an object and call the above methods.
Define a class to accept values in integer array of size 10. Sort them in an ascending order using selection sort technique. Display the sorted array.