Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
13 views4 pages

Class 10

The document outlines a Java programming exam divided into three sections: Section A includes multiple-choice and short answer questions worth 40 marks, Section B consists of coding tasks and predictions worth 30 marks, and Section C requires writing Java programs and defining a class, also worth 30 marks. Each question in Section A carries 2 marks, while questions in Sections B and C have varying marks. The exam tests knowledge of Java syntax, programming concepts, and practical coding skills.

Uploaded by

rbanerjee162
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

Class 10

The document outlines a Java programming exam divided into three sections: Section A includes multiple-choice and short answer questions worth 40 marks, Section B consists of coding tasks and predictions worth 30 marks, and Section C requires writing Java programs and defining a class, also worth 30 marks. Each question in Section A carries 2 marks, while questions in Sections B and C have varying marks. The exam tests knowledge of Java syntax, programming concepts, and practical coding skills.

Uploaded by

rbanerjee162
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Section A (40 Marks)

Each question carries 2 marks

Q1. Name the following:


(i) The feature of Java which allows execution of the same bytecode on any operating system.
(ii) The operator with the highest precedence in the expression a + b * c / d % e.
(iii) The method that returns the length of a string object.
(iv) The default value of an int variable in Java.
(v) The keyword used to create objects in Java.

Q2. State whether the following statements are True or False:


(i) The switch statement in Java can use float as a case label.
(ii) Java is a case-sensitive programming language.
(iii) The break statement transfers control back to the calling method.
(iv) char type in Java occupies 1 byte of memory.
(v) Math.random() generates a value between 0.0 and 1.0.

Q3. Multiple Choice Questions (choose the correct option):


(i) Which among these is not a valid Java keyword?

• a. static

• b. class

• c. If

• d. void

(ii) The size of boolean type variable in Java is:

• a. 1 byte

• b. JVM dependent

• c. 2 bytes

• d. Not defined

(iii) Which method converts a lowercase character to uppercase?

• a. String.toUpperCase()

• b. Character.toUpperCase(char)

• c. toUpperCase()

• d. Character.isUpperCase(char)

(iv) To declare an array of 20 integers, the correct statement is:

• a. int arr[20];

• b. int arr() = new int[20];

• c. int arr[] = new int[20];

• d. array arr = int[20];


(v) The wrapper class for primitive type double is:

• a. Double

• b. Float

• c. Integer

• d. Character

Q4. Write one difference between:


(i) Actual parameter and Formal parameter
(ii) break and continue
(iii) Default constructor and Parameterized constructor
(iv) while loop and do-while loop
(v) equals() and == operator

Section B (30 Marks)

Each question carries 5 marks

Q5. Rewrite the following code using a single if statement:

if(ch=='a')

System.out.println("Vowel");

else if(ch=='A')

System.out.println("Vowel");

Q6. Write the output of the following code:

int a=5, b=2;

b*=a++ + ++b - ++a;

System.out.println("a= "+a);

System.out.println("b= "+b);

Q7. Predict the output of the following program:

String s1 = "Coding";

String s2 = "Code";

System.out.println(s1.compareTo(s2));

System.out.println(s1.substring(0,3));

System.out.println(s2.concat("Class"));

Q8. Consider the array:

int x[][] = { {2,4,6}, {1,3,5}, {7,9,11} };


(i) Write the element at row 2, column 3.
(ii) Find the sum of elements of first row.
(iii) State the number of rows.
(iv) Write the statement to access the last element.
(v) Evaluate x[1][0] + x[2][2].

Q9. Correct the following erroneous code and mention the error type:

String num="100";

int n = Integer.parseDouble(num);

double r = Math.sqrt(n);

System.out.println(r);

Q10. Write a Java method prototype:


(i) average which takes two double arguments and returns a double.
(ii) isEven which takes one int argument and returns a boolean.

Section C (30 Marks)

Each question carries 10 marks

Q11. Write a Java program to input a number and check whether it is an Armstrong Number.
Example:

• Input: 153 → Output: Armstrong Number

• Input: 123 → Output: Not Armstrong Number

Q12. Write a Java program to input marks of 10 students into a 1D array and then display:

• The highest mark

• The lowest mark

• The average mark

Q13.

Define a class BankAccount with:

• Instance variables:

o String accountNumber

o String accountHolderName

o double balance

• Constructor to initialize the account.


• Method deposit(double amount) → add amount to balance.

• Method withdraw(double amount) → deduct amount only if sufficient balance, otherwise


show "Insufficient Balance".

• Method calculateCompoundInterest(double rate, int years) → calculate and return


compound interest using the formula: where P = balance, r = rate, t = years.

• Method display() → display account details (number, name, balance).

Task in main():

1. Create an object with initial balance.

2. Perform deposit and withdrawal.

3. Display account details.

4. Calculate and print the balance after applying compound interest for 3 years at 5%.

You might also like