0% found this document useful (0 votes)
26 views2 pages

Class 10 23 August 2023

The document contains a series of questions related to programming concepts, Java methods, and class design. It includes multiple-choice questions, coding exercises, and class design tasks for a cab service and character frequency counting. The content is aimed at testing knowledge of Java programming and object-oriented principles.

Uploaded by

Rituraj Pradhan
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)
26 views2 pages

Class 10 23 August 2023

The document contains a series of questions related to programming concepts, Java methods, and class design. It includes multiple-choice questions, coding exercises, and class design tasks for a cab service and character frequency counting. The content is aimed at testing knowledge of Java programming and object-oriented principles.

Uploaded by

Rituraj Pradhan
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/ 2

(1) Wrapping up of data and methods together as one unit is termed as:

(a) Inheritance (b) Polymorphism (c) Encapsulation (d) Abstraction


(2) Which one of the following is not a String class method?
(a) concat() (b) nextLine() (c) trim() (d) length()
(3) Math.pow(625, 0.5 ) + Math.sqrt(144)
(a) 17.0 (b) 13.0 (c) 37.0 (d) 13
(4) The number of bytes occupied by the constant 37.15f is:
(a) Four bytes (b) two bytes (c) Eight bytes (d) one byte
(5i) FOR loop is a
(a) fixed loop (b) infinite loop (c) exit controlled (d) unfixed loop
(6) Give the output of the following string methods:
"MALAYALAM".substring(0 , 5)+ "ASIA".charAt(0);
(a) MALAYAASIA (b) MALAYA (c) MALAYASIA (d) MALAY
(7) A method which modifies the argument passed to it:
(a) static method (b) constructor (c) pure method (d) impure method
(8) int res=’A’+5; What is the value of res?
(a) 70 (b) F (c) 65 (d) error
(9) The style of expressing multiline line comment is:
(a) /* comment*/ (b) * comment (c) // comment (d) /* comment
(10i) The method to check if a character is an vowel or not is:
(a) ch.isVowel() (b) isVowel(char) (c) Character.isVowel(char) (d) none
(11) Value returned by function compareTo() if the invoking string is equal to the string compared?
(a) 0 (b) less than 0 (c) greater than 0 (d) true
(12) _________ may be define as the process of identifying only the required details of an object
ignoring the irrelevant details.
(a) Abstraction (b) inheritance (c) Polymorphism (d) Encapsulation
(13) Searching method which finds the middle value from a sorted array.
(a) bubble (b) linear (c) binary (d) selection
(14) Name the type of error that occurs for the following statement:
System.out.println(str.charAt(str.length()));
(a) Syntax error (b) run time error (c) logical error (d) no error
(15) Java constructor is like a method without …………..
a) Argument list (b)Return type (c)Statements (d)None
(16) The expression which uses > = operator is known as:
(a) relational (b) logical (c) arithmetic (d) assignment
(17) Name the package that contains String classes:
(a) java.lang (b) java.util (c) java .io (d) java.awt
(18) Assertion(A): call by reference is known as impure method.
Reason(R): The original value of variable changes as operation is performed on copied values.
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation (A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
(19) Assertion (A): String is immutable, once created, a String object always has the same value.
Reason (R): To modify a string, you have to create a new String object.
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation (A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
(20) Assertion (A): The Java is platform dependent programming language.
Reason (R): The Java compiler encodes the source code into machine independent coding known as
ByteCode.
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation (A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true

Page 1
Question 2
(1) Evaluate the expression: z += a++ % --b+ --a + ++b; where a = 15, b = 8, z = 20
(2) int c=-5, a=5, j;
while(a ++ <=10)
for(j=1;j<=a ; j++)
c++;
How many times will the inner loop execute? What is the final value of c?
(3) “REDUCE”.compareTo(“REFUSE”)+“MADAGASCAR”.lastIndexOf(‘A’)
(4) Define the term token.
(5) Consider the following array and answer the questions given below:
int x [ ] = (23, 45, 67, 12, 45, 89, 24, 12, 9, 7}
(a) What is the size of the array?
(b) What is the index of value 89?

Question 3
A private Cab service company provides service within the city at the
following rates:
NON AC CAR AC CAR
UPTO 5 KM Rs 150 /- Rs 120 /-

BEYOND 5 KM Rs 10/- PER Rs 08/- PER KM


KM
Design a class CabService with the following description:
Member variables /data members:
String car_type - To store the type of car (AC or NON AC)
double km - To store the kilometer travelled
double bill - To calculate and store the bill amount
Member methods :
CabService() - Default constructor to initialize data members.String data members to '' '' and double
data members to 0.0.
void accept () - To accept car_type and km (using Scanner class only).
void calculate () - To calculate the bill as per the rules given above.
void display() - To display the bill as per the following format
CAR TYPE:
KILOMETER TRAVELLED:
TOTAL BILL:
Create an object of the class in the main method and invoke the member methods.

Question 4
Write a program to input a sentence and convert it into uppercase and display each word in a separate
line. Example: Input: India is my country
Output : INDIA
IS
MY
COUNTRY

Question 5
Design a class to overload a method Number( ) as follows:
(i) void Number(int num , int d) - To count and display the frequency of a digit in a number.
Example: num = 2565685, d = 5
Frequency of digit 5 = 3
(ii) void Number(String str, char ch) - To count and display the frequency of a character (both cases) in
a string.
Example: str = malayalam, ch = a
Frequency of character a = 4

Page 2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy