Class 9 I. Choose the correct answer: 1. Which one is an invalid identifier ? a) Total b) Total_Marks c) 1Total To convert an int data type to a String data type, which method will you use? a) parselnt( ) b) ValueOf( ) c) toString( ) Which of these increases the value of A by 1 ? a) A++ b) ++A c) A = A + 1 The operator used for multiplication is a) ** b) ^ c) X Which one of these is not a logical operator ? a) || b) + c) && It assigns value to a variable a) Assignment Operator b) Increment Operator c) Decrement Operator Which of these Operator is used for finding the remainder ? a) + b) * c) % "Java" is an example of _______________________ data type. a) Int b) Long c) Float The control that allows the user to select an option from two or more options. a) Radio Button b) Check Box c) Text Area This control allows the user to select more than one Option. i. Combo Box b) Check Box c) List Box A control containing group of items and allowing multiple selection a) Combo Box b) List Box c) Check Box A rectangular shape in which other controls can be placed a) List Box b) Panel c) Combo Box A control that contains a group of items and allows only one Selection. a) List Box b) Check Box c) Text Area A single character enclosed in apostrophe is a) Constant b) String Constant c) Numeric Constant A portion of memory used to store a value is a) Variable b) Constant c) Data The method used to connect string data type to int is a) toString( ) b) Parse( ) c) Integer.parseInt Operators that require only one operated are called a) Binary b) Unary c) Tenary Operators and Operands together form a/an a) Expression b) Equation c) Calculation Find the odd one out a) && b) || c) ! The Operators used to compare two expressions is a) Arithmetic b) Relational c) Logical 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. d) TotalMarks d) All of these d) All of these d) * d) ! d) Relational Operator d) d) String d) Panel d) Radio Button d) None of these d) Check Box d) Combo Box d) Character Constant d) None of these d) Float.parseFloat d) None of these d) None of these d) + d) None of these -2II. Fill in the blanks: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. Adding two strings one after another is called Concatenation. The increment operator increases the value of variable by One. A Variable is a portion of memory used to store a value. The Constant is a fixed value that does not change during the execution of a program. The % (modulus) is a/an arithmetic operator. Relational operations result in either true or false. The unary operator takes only one operand. The Assignment operator is used to assign a value to a variable. The data entered in Text Field by the user has String data type. Selected Index property sets the Index value of the selected option in the list. The term Combo Box is short for combination box. Every variable must be given a Data type. Arithmetic Operators are called binary operators as they require two operands. The + operator is used for Concatenation. toString( ) method is used to convert numeric data type to string data type. A panel is a container control. III. Answer in TWO or THREE lines: 1. Differentiate between Radio button and Check box control. Radio Button Check Box Radio Button control is used when the user It is similar to a radio button but here, you can is offered to select only one option from two select more than one option at a time. or more given options. 2. What is the purpose of enabled property ? It determines whether the control can respond to an event or not. Its value is either true or false. True means it is enabled and false means it is disabled. 3. Differentiate between List Box and Combo box. List Box Combo Box The List control is used in case you want to The term Combo box is short for Combination select one or more items from a list of items. Box. It is so named because it combines the features of Text Field and List. 4. 5. What are the three types of selection modes used in the List control ? SINGLE - Allows selection of a single item SINGLE_INTERVAL - Allows continuous selection using SHIFT key MULTIPLE_INTERVAL - Allows multiple selections using the CTRL key. Define variable. When a program runs, any data that it uses must be stored in memory (RAM). A variable is a portion in memory used to store a value. A variable must be identified by an identifier. 6. Write a short note on data type. Every variable must be given a data type. The data type decides the type of value that can be stored and its range. Java variable could be either numeric or alphanumeric 7. What are the types of constants ? Constants are classified into Integer constant, Floating point constant, Character constant and String constant. Some examples are given below: int A = 692; float B = 548.12; char c = ‘D’; String D = “Computer Activities”; -38. Tabulate the numeric data types in JAVA. Data Type 9. Memory required (bytes) byte 1 short 2 int 4 long 8 float 4 double 8 List down the rules for naming an identifier. A Java variable name or identifier must begin with an alphabet and can be followed by an alphabet, a digit or an underscore (_) sign. It must not be a reserved word (a word that holds special meaning for the compiler). Java identifiers are case sensitive. i.e., Total and total are two distinct identifiers. 10. What is the use of parse( ) method ? parse( ) methods are used to convert String data type to int, long, float and double. For example, int a = Integer.parseInt(jTextField1.getText()); float a = Float.parseFloat(jTextField1.getText()); long a = Long.parseLong(jTextField1.getText()); double a = Double.parseDouble(jTextField1.getText()); 11. Write a note on toString( ) method. It converts numeric values to String data type. For example, int a = 56; float b = 986.5; double c = 19786.345; long d = 40000; can be converted to String data type in the following way: String S1 = Integer.toString(a); String S2 = Long.toString(b); String S3 = Float.toString(c); String S4 = Double.toString(d); 12. Write a note on Assignment operator. The Assignment operator is used to assign or store a value to a variable. If the variable already has a value stored, it is replaced with the newly assigned value. A = 24; It assigns the value 24 to the variable A. 13. What is the use of unary operator ? The symbol of unary minus is the same as the sign used for subtraction. It is used to change the algebraic sign of value. For example, A = -45; It assigns the value -45 to A. By default, the value is assumed to be positive if no sign specified. 14. Write a note on Increment and Decrement operators. The increment and decrement operators are unary operators as they require only one operand. The increment operator (++) increases the value stored in a variable by one. The decrement operator (--) decreases the value stored in a variable by one. 15. What is concatenation ? Give an example. Concatenation refers to making one string from two strings by placing one after another. The ‘+’ operator is used for concatenation. If one of the operands in concatenation is a string, the other operand is also converted to a string. -4IV. Answer in detail: 1. Tabulate Arithmetic, Relational and Logical operators in JAVA. 2. Create a JAVA GUI project to enter two numbers and display their sum on the click of the Click button. 3. R & R Bros, Public company has given a hike of 9% in the salary of all its workers in a factory. Create a JAVA GUI application to enter the salary of an employee display 9% of the salary and new salary (old salary + 9% of salary) on clicking the Calculate button. 4. A Coaching centre conducted an exam on three topics – Analytical Skill, Logical Ability and General Knowledge. Each one was of 100 marks. Create a JAVA GUI application that allows the user to enter marks and carry out the following functions. ************************
© Copyright 2025 Paperzz