z ó : À ] t ] p z p í ì u l w À ] } µ z [ } w r y µ ] } v v l

18
Compiled by Nuzhat Ibrahim Memon 1 Textual Exercise (1) How many basic (primitive) data types are supported in Java ? (A) 2 (B) 4 (C) 8 (D) 16 (2) What is the default data type of floating point literal? (A) Int (B) long (C) float (D) double (3) Which character set is used for char data type in java? (A) Unicode (B) ASCII (C) EBCIDIC (D) All of these (4) Which of the following is compiled error free? (A) for(;;){int i=7}; (B) while (1) { int i=7}; (C) while (true){int i=7} (D) All of these (5) which of the following is not allowed as first character in valid variable name? (A) underscore(_) (B) digit (C) letter (D) dollar($) (6) Which of the following is not a basic data type in java? (A) Char (B) long (C) byte (D) String (7) What is the default value of Boolean type data? (A) null (B) true (C) false (D) 0 (8) what will be the result of arithmetic expression 7/2? (A) 3 (B) 3.5 (C) 1 (D) 0 (9) what will be the result of arithmetic expression -7%2? (B) -3 (B) -1 (C) 1 (D) -3.5 (10)what will be the result of arithmetic expression -7.5%2? (1) -3 (B) -1.5 (C) 1.5 (D) Error Std. 12 (General) | March – 2015 (11) What sign is used for creating API documentation from the code ? (A) // (B)/*….*/ (C)/**…. */ (D) \\ (12)In Java. Which of the following looping is exit controlled? (A) for (B) while (C) do….while (D) if….then…else (13)In java, which of the following is not allowed as first character in valid variable name? (A)_(underscore) (B) digit (C) letter (D) $ (Dollar) (14) What is known as when program written in Java are compiled in to machine language for a computer ? (A) Java Visible Machine (B) Java Virtual Machine (C) Java View Modifier (D) Java Visible Modifier (15) What is known as post decrement in java when operator is used after variable name ? (A) ++ (B) - - (C) = = (D) =< (16) By using which extension file java interpreter byte code executes ? (A) .java (B) .class (C) .txt (D) .html (17) In Java, which statement is used when there are many alternative actions to be taken depending upon the value of a variable or expression? (A) Switch (B) Nested if (C) Control (D) Repeat (18) What kind of primitive data types are provided in Java from the following? (A) boolean (B) double (C) char (D) All of these (19) What is the value of float data type in Java ? (A) Integer (B) Real (C) Character (D) Boolean (20) what will be the result of arithmetic expression -7.5%2? (A)-3 (B) -1.5 (C) 1.5 (D) Error Chapter 7 Java Basics Previous Years’ Board Paper - Question Bank Weightage 10 marks

Upload: others

Post on 03-Apr-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

Compiled by Nuzhat Ibrahim Memon 1

Textual Exercise (1) How many basic (primitive) data types are supported in Java ?

(A) 2 (B) 4 (C) 8 (D) 16 (2) What is the default data type of floating point literal?

(A) Int (B) long (C) float (D) double (3) Which character set is used for char data type in java?

(A) Unicode (B) ASCII (C) EBCIDIC (D) All of these (4) Which of the following is compiled error free?

(A) for(;;){int i=7}; (B) while (1) { int i=7}; (C) while (true){int i=7} (D) All of these (5) which of the following is not allowed as first character in valid variable name?

(A) underscore(_) (B) digit (C) letter (D) dollar($) (6) Which of the following is not a basic data type in java?

(A) Char (B) long (C) byte (D) String (7) What is the default value of Boolean type data?

(A) null (B) true (C) false (D) 0 (8) what will be the result of arithmetic expression 7/2?

(A) 3 (B) 3.5 (C) 1 (D) 0 (9) what will be the result of arithmetic expression -7%2?

(B) -3 (B) -1 (C) 1 (D) -3.5 (10)what will be the result of arithmetic expression -7.5%2? (1) -3 (B) -1.5 (C) 1.5 (D) Error Std. 12 (General) | March – 2015 (11) What sign is used for creating API documentation from the code ? (A) // (B)/*….*/ (C)/**…. */ (D) \\ (12)In Java. Which of the following looping is exit controlled? (A) for (B) while (C) do….while (D) if….then…else (13)In java, which of the following is not allowed as first character in valid variable name? (A)_(underscore) (B) digit (C) letter (D) $ (Dollar) (14) What is known as when program written in Java are compiled in to machine language for a computer ? (A) Java Visible Machine (B) Java Virtual Machine (C) Java View Modifier (D) Java Visible Modifier (15) What is known as post decrement in java when operator is used after variable name ? (A) ++ (B) - - (C) = = (D) =< (16) By using which extension file java interpreter byte code executes ? (A) .java (B) .class (C) .txt (D) .html (17) In Java, which statement is used when there are many alternative actions to be taken depending upon the value of a variable or expression? (A) Switch (B) Nested if (C) Control (D) Repeat (18) What kind of primitive data types are provided in Java from the following? (A) boolean (B) double (C) char (D) All of these (19) What is the value of float data type in Java ? (A) Integer (B) Real (C) Character (D) Boolean (20) what will be the result of arithmetic expression -7.5%2? (A)-3 (B) -1.5 (C) 1.5 (D) Error

Chapter 7 Java Basics Previous Years’ Board Paper - Question Bank Weightage 10 marks

Compiled by Nuzhat Ibrahim Memon 2

Std. 12 (Science) | March – 2015 (21) Java language is developed by which company ? (A) Sun Microsystem (B) Sun Java System (C) Sun System (D) Sun Microsoft (22)The machine language for the Java Virtual Machine is called what? (A) code byte (B) Type code (C) Java Bytecode (D) Java Code (23) While creating Java what must be the same ? (A) folder name, filename (B) class name, extension (C) class name, folder name (D) class name, file name (24) When the program gets compiled without error, compiler creates a file with which extension ? (A) .comp (B) .txt (C) .java (D) .class (25) The process of compiling and executing a java application is as follows. What is missing from given chart ? Java Source file(.java)java compiler (javac) ? JVM- Java Interpreter (java) (A) Java class(*.exe) (B) Java typecode (*.obj) (C)Java Bytecode (*.class) (D) Java typecode (*.obj) (26) Which of the following is right way to define variable ? (A) $age (B) discount rate (C) 4youpeople (D) %discount (27) String literals is a sequence of characters enclosed in which quotes ? (A) ‘ ‘ (B) “ “ (C) () (D) {} Std. 12 (General) | March – 2015 (27)Which of the two symbols are used in the conditional operator in Java ? (A) : and * (B) # and ? (C) ? and : (D) / and ? (29) While using shorthand version of assignment, it is defined as a+=b where a is 7 and b is 8 then what will result of a ? (A) 8 (B) 49 (C) 14 (D) 15 (30) When two operators are having different priority, then an operator with higher precedence is operate________

(A) first (B) last (C) second (D) middle (31)What will be output of following program? class abc{ public static void main(string[] S){ for(int i=0;i<10;i++){ SYSTEM.out.println(i); } } }

(A) error (B) i (C) Display 1 to 10 (D) 1,2,3,…….10 (32) Control structure branches are used to choose among two or more possible courses of action, is called as what ? (A) More structure (B) Loop structure (C) Addition structure (D) Selective structure (33) Switch statement can be stopped using which statement ? (A) break (B) run (C) loop (D) error (34) do ….. while loop is which type of loop ? (A) Loop controlled (B) Break controlled (C) Exit controlled (D) Entry controlled (35) To use a labeled loop, which symbol is added before the loop? (A) * (B) $ (C) : (D) # (36)in java, the text written in /*….*/ is considered as what ? (A) Method (B) Comment (C) Function (D) Variable (37) user can create Java source file by using ____________ application? (A) Scite Editor (B) ASCII text editor (C)Both (A) & (B) (D) None of these (38) The definition of the method (function) in java consists of function head and the sequence of statement

enclosed in which bracket? (A) {} (B) <> (C) () (D) []

Compiled by Nuzhat Ibrahim Memon 3

(39) Java supports how many primitive data types ? (A) 3 (B) 8 (C) 4 (D) 7

(40) Which of the following data type is used for real numbers? (A) short (B) char (C) long (D) double Std. 12 (General) | March – 2016 (41) From the following which is considered as one of the ideal language for distributing executable program and also general purpose programming language for developing programs that are easily usable and portable across different platforms? (A) c language (B) java (C) visual basic (D) Javascript (42) Which extension is used to source file of java language, written in a text editor? (A) .class (B) .html (C) .jpg (D) .java (43) From the following which methods are used to display results? (A) system.out.print() (B) system.out.println() (C) Both (A) & (B) (D) system.out.display() (44) In java, the program is compiled without any error, which command is used to execute it? (A) ToolsGo (B) ToolsRun (C) ToolsBuild (D) ToolsCompile (45)How many primitive data types are there in Java? (A) 5 (B) 6 (C) 7 (D) 8 (46) From the following which are the examples of reserved words in Java? (A) class (B) public (C) static (D) All of these (47) A name used for a constant value is known as what in Java ? (A) String (B) Array (C) Literal (D) Class (48)Which sign is used to insert single line comment in Java? (A) /* and */ (B) /** and */ (C) // (D) # (49)From the following which is not logical operator in Java? (A) AND (B) OR (C) NOT (D) Equal to (50)From the following which is true syntax of conditional operator? (A) <exp>=<exp>=<expr> (B) <exp>?<exp>:<expr> (C) <exp>;<exp>?<expr> (D) <exp>=<exp>:<expr> Std. 12 (Science) | March – 2016 (51)In java, at which level platform –independence is possible due to bytecode interpreter? (A) browser (B) source (C) machine (D) binary (52) in Java, the machine language for Java Virtual Machine is known as which code? (A) java filecode (B) java bytecode (C) java intcode (D) java sourcecode (53)To compile the java program we have to type what in front of source filename? (A) javac filename.java (B) javac filename (C) javac filename.html (D) java filename.java (54) In Java program is compiled without any error we can execute it in SciTE editor by which menu-option? (A) compileRunGo (B) EditGo (C) ToolsGo (D) FileGo (55)Java supports how many primitive data types? (A) 2 (B) 4 (C) 6 (D) 8 (56) What is the storage space for datatype float in java? (A) 1 byte (B) 2 byte (C) 4 byte (D) 8 byte (57)Real numbers in Java are compliant with which of the following? (A) IEE 36 (B) IEE 16 (C) IEEE 780 (D) IEEE 754 (58) In java, variable name should begin with which of the following? (A) alphabet (B) underscore(_) (C) Dollar sign (D) All of these (59) In java, a name used for constant value is known as what? (A) string return (B) Literal (C) Unicode Quote (D) ASCII

Compiled by Nuzhat Ibrahim Memon 4

(60) Java 7 also supports binary numbers, using digits 0 and 1 but it should be prefix by which of the following? (A) 0b or 0B (B) B (C)B1 (D) b0 (61)In java, for type boolean there are precisely two literals, which are they? (A) Y or N (B) 0 and 1 (C) True or False (D) Yes or No (62) in Java, characters are stored by how many bit Unicode characters? (A) 4-bit (B) 8-bit (C) 16-bit (D) 32 bit (63)String literals in java is a sequence of characters which can be enclosed in which of the following? (A) $...$ (B) “ “ (C) ‘ ’ (D) `` (64)In java, documentation comments begins and ends with which of the following ? (A) /**…*/ (B) /*….*/ (C) /*…/ (D) // (65)Arithmetic operators in java, can be applied on which numeric data? (A) short (B) float (C) byte (D) all of these (66)In java, which of the following is known as unary operators for increment and decrement operators? (A) >== and <= (B) + and - (C) == and != (D) ++ and - - (67)Which of the following is considered as comparison operator in Java? (A) = (B) / (C) % (D) != (68) In java,logical operators are also called which of the following operators if they operate on Boolean operands? (A) assignment operator (B) Boolean operator (C) Increment operator (D) Relational operator (69)In java, conditional uses which two symbols in expression to delimit three operands? (A) ? and * (B) . and : (C) ? and : (D) : and ; (70)In Java, a block statement is a group of statements enclosed between which pairs of braces? (A)[/…../] (B) {} (C) () (D) [] Std. 12 (General) | March – 2017 (71) Java language was developed by whom? (A) Sun Microsystem (B) Oracle (C) Netscape (D) Microsoft (72) When java program created java source file using text editor, which file extension should be given? (A) .class (B) .html (C) .obj (D) .java (73) What is the full form of JVM? (A) Java Visibility Machine (B) Java Visual Machine (C) Java Virtual Machine (D) Java Vocal Machine (74) Which menu-option is used to compile source program to SciTE? (A) EditCompile (B) FormatCompile (C) ToolsCompile (D) FileCompile (75) What is the default value of boolean data type of java? (A) False (B) True (C) 0 (D) 1 (76) From the following which is the illegal name of variable in java? (A) 4me (B) result (C) amount$ (D) price$ (77) The name used for a constant value is known as what in java? (A) String (B) Array (C) Literal (D) class (78)which sign indicates single line comment in Java? (A) /*…*/ (B) /**…*/ (C) // (D) # (79) From the following which is not a comparison operator in java? (A)> (B) < (C) >= (D) + (80) Which operator can be used to concatenate a string in java? (A)= (B) + (C) & (D) * Std. 12 (Science) | March – 2017 (81) Which of the Java syntax is very similar to which language? (A)Fortran (B) SQL (C) C (D) FoxPro

Compiled by Nuzhat Ibrahim Memon 5

(82) At which level platform-independence is possible due to bytecode interpreter? (A) Bottom level (B) Binary level (C) Source level (D) High level (83)The alphabet D in JDK stands for which of the following? (A) Department (B) Development (C) Design (D) Desktop (84) Which of the following company is best known for its high-end unix workstations? (A) Sun Microsoft (B) Sun Microchip (C) Sun Microsystems (D) Sun Microsource (85) Programs written in Java are compiled into machine language for a computer that doesn’t really exists. This type

of computer is known as what? (A) Java Virtual Model (B) Java verifier Machine (C)Java Vertical Machine (D) Java Virtual Machine (86) The only disadvantage of using bytecode is which of the following ? (A) High execution speed (B) Fast execution speed (C) Slow execution speed (D) Random execution speed (87) In java, java source files name and class they define name should be what? (A)Totally different (B) Same (C) Different (D) vice versa (88) What is the extension of java source file? (A) .j (B) .java (C) .class (D) .jav (89) Which of the following way user can run “abc.java” source program through the application using java

interpreter? (A) java ABC (B) java abc.obj (C) java abc.class (D) java abc (90) In java, the text written in which of the following are comments? (A) \*…\* (B) /*….*/ (C) /*…*\ (D) \*….*/ (91) Which of the following editor is used to create java source program in ubuntu? (A) Jedit (B) Notebook (C) Workpad (D) SciTE (92) Java consists of function header and the sequence of statements enclosed between which braces? (A) <> (B) [] (C) {} (D) () (93) Java supports how many primitive data types ?

(A) 6 (B) 7 (C) 8 (D) 9 (94) Which of the following data type is hold real numbers?

(A) long (B) double (C) char (D) byte (95) A name used to refer to the data stored in memory is called what? (A) value (B) object (C) variable (D) function (96) Which of the following is illegal way to define variable name in Java? (A) $price (B) %sale (C) B4U (D) Amount$ (97) Which of the following is not reserved word in java? (A) class (B) else (C) static (D) rate (98) Control structures in Java is divided into two types: Loops and what? (A) Message (B) Function (C) Branches (D) Alerts (99) In java, which statement is used to exit from the loop structure? (A) stop (B) exit (C) out (D) break (100) Which of the following is exit-controlled loop in java? (A) for (B) do…while (C) while (D) loop Std. 12 (General) | March – 2018 (101) When the program gets compiled without errors, compiler created which type of file extension in java? (A) .class (B) .java (C) .c++ (D) .c (102) From the following which is not compiled or interpreted in Java? (A) if statement (B) function (C) comment (D) variable (103) Which command is used if the program is compiled without any error? (A) ToolsExecute (B) EditGo (C) ToolsGo (D) Toolscompile

Compiled by Nuzhat Ibrahim Memon 6

(104) In java, Boolean data type hold which logical values? (A) Y,N (B) 0,1 (C) True, False (D) Yes, No (105) From the following which legal name of variable ? (A) birth date (B) birth_date (C) %discount (D) 4balance (106) Which numeric digits are used for hexadecimal numbers (16 digits) in integer literals in Java? (A) 0 to 8 and A to F (B) 0 to 9 and A to F (C) 0 to 15 (D) 0 to 16 (107) What is the symbol for multi-line comment in Java program? (A) /*…*/ (B) //*…*// (C) *….* (D) // (108) In Java, what will be the result of arithmetic expression 8%3? (A) 8 (B) 3 (C) 4 (D) 2 (109) Which sign is used for “A not equal to B” in comparison operator of java? (A) A≠B (B) A!=B (C) A not equal B (D) A==B Std. 12 (Science) | March – 2018 (110) Which of the following statement is true for java language?

(i) Java language was developed by sun microsystem (ii) Java is an object oriented language (iii)Java is not platform-independent at both the source and binary level (A) only (i) and (ii) (B) only (ii) and (iii) (C) only (i) and (iii) (D) (i), (ii) and (iii) (111) In java, float data type takes how many bytes of storage space? (A) 2 bytes (B) 4 bytes (C) 8 bytes (D) 16 bytes (112) In java, variable name must begin with which of the following? (A) alphabet (B) digit (C) spaces (D) % (113) Which of the following statement is right for Boolean literal in Java? (i) 0 is treated as false and 1 is treated as true

(ii) Literals are to be typed without quotes (iii) For the Boolean type, there are two literals:true and false

(A) (i),(ii) and (iii) (B) only (ii) and (iii) (C) only (i) and (iii) (D) only (i) and (ii) (114) Which of the following is not a basic arithmetic operator of Java? (A) \ (B) - (C) * (D) + (115) Which of the following is not a comparison operator in Java ? (A) != (B) >= (C) = (D) <= (116) How many types of control structures are there in Java? (A) Four (B) Two (C) Three (D) one (117)In the switch statement of java, the test expression should be of which of the following type? (A) boolean (B) double (C) byte (D) float (118) In jva, which of the following loop is exit-controlled or post-test loop construct? (A) switch (B) while loop (C) do….while loop (D) for loop (119) After execution of which statement in the loop of java, all the following statements in a body of the loop are

skipped and no further iteration take place? (A) loop (B) go (C) break (D) continue

Std. 12 (General) | March – 2019 (120) In Java, What is the default value of Boolean type data? (A) True (B) false (C) 1 (D) 0

(121) In java, which of the following is used to repeat a sequence of statements over and over until some condition occurs?

(A) Loops (B) Branches (C) Breaks (D) Sets (122) Java supports how many primitive data types ? (A) 2 (B) 4 (C) 6 (D) 8

Compiled by Nuzhat Ibrahim Memon 7

(123) Who developed Java language? (A) Microsoft (B) Adobe (C) Google (D) Sun Microsystems (124) What is the machine language for the Java Virtual Machine known as? (A) Java source code (B) java application code (C) Java program code (D) Java byte code (125) in SciTE editor, which menu-option is used to compile java source program? (A) ToolsGo (B) Toolscompile (C) Toolsbuidcode (D) FileRun (126) Which of the following is not used for comment in Java? (A) // (B) /*….*/ (C) //*….*// (D) /**…..*/ (127) What should be the extension of java source program file? (A) .class (B).jar (C) .htm (D) .java (128) Which of the following is a comparison operator of java? (A) + (B) % (C) < (D) * (129) In Java, which statement is used to skip the following statements in a loop and continue with next iteration ? (A) break (B) continue (C) go (D) run Std. 12 (Science) | March – 2019 (130) Where java language developed? (A) Apple systems (B) SON Microsystems (C) Oracle systems (D) Sun Microsystems (131) What is the full form of JVM? (A) Java Vertical Machine (B) Java Virtual Machine (C) Java Varity Machine (D) Java Visual Machine (132) Which of the following editor is used to create java file in ubuntu? (A) Calc (B) Writer (C) Scite (D) Wordpad (133) Which of the following is right when java file is created? (A) Java source file & class name must be different (B) Java source file & class name must be same (C) Name must start with Number ‘2’ only (D) Name must have symbol ‘$’ at the end (134) Which of the following is comment statement in Java? (A) /#....#/ (B) \*…*\ (C) /*…..*/ (D) /*…../* (135) Which of the following command is given in JDK using java interpreter? (A) Run Call Cost (B) javarc Call Cost (C) Java Call Cost (D) JavaRun Call Cost (136) Which of the following is missing from compilation process to execute java application ?

(A) Java Bitecodefile(*.csc) (B) Java Bytecode file (*.class) (C) Java Bookcodefile(*.cla) (D) JavaCompilercode(*.javacr) (137) How many basic (primitive) data types are supported in java? (A) .4 (B) 2 (C) 8 (D) 16 (138) Which of the following escape code is used for backspace in java? (A) \t (B) \n (C) \b (D) \k

JVM-Java Interpreter(Java)

Java Compiler (Javac)

Java Source File (usually have extension.java)

Compiled by Nuzhat Ibrahim Memon 8

(139) which of the following loop is exit controlled loop in java? (A) .do…while (B) for (C) for…while (D)exit….while Std. 12 (General) | March – 2020 (140) How many basic (primitive) data types are supported in Java ? (A) 2 (B) 4 (C) 8 (D) 16

(141) In switch statement, if no match is found between test expression and case values, then which statement will be executed?

(A) break (B) continue (C) if…else (D) default (142) If a=12.5 and b=7.2, then after executing a%b, what will be the remainder?

(A) 1 (B) 5.3 (C) 5.0 (D) 1.22 (143) When a variable is declared inside a block, what is it called?

(A) Global (B) Local (C) Label (D) Repetitive (144) Which of the following is a proper option for the statement “Is A not equal to B”?

(B) A <> B (B) A ≠ B (C) A NOT B (D) A!= B (145) If the conditional ternary is next = (N%2==0)?(N/2):(3*N+1); where N=7 then what will be the value of variable next?

(A) 22 (B) 7 (C) 3.5 (D) 0 (146) Which symbol is used to begin single line comment?

(A) /* … */ (B) /** …. */ (C) // (D) \\ (147) By using which of the following statements the following statements in a body of the loop are skipped and control is transferred at the first statement after the switch statement?

(A) continue (B) default (C) break (D) for (148) Which logical operator returns true only if its operands are different (one true and one false) and false otherwise?

(A) XOR (B) OR (C) AND (D) NOT (149) Which of the following is not a proper example of Hexa decimal number? (A) OXFF7A (B) OX39A2 (C) OX532D (D) OABC Std. 12 (Science) | March – 2020 (150) How many primitive data types are supported in Java ? (A) 2 (B) 4 (C) 8 (D) 16

(151) Java language was developed by which of the following company? (A) Sun Microsystem (B) Netscape (C) Microsoft (D) Oracle (152) Which of the following extension file is generated by compiler, when the program gets compiled without error in java ? (A) .java (B) .c (C) .org (D) .class (153) Single line comment begins with which sign in Java? (A) /* (B) // (C) /** (D) All of the above (154) What will be the result of arithmetic experssin 9%2 ? (A) 4.5 (B) 1 (C) 4 (D) 0 (155) What is it called when ++ operator is used after variable name in Java? (A) post increment (B) pre increment (C) increment pre (D) pre decrement (156) Which of the following is used to repeat a sequence of statements over and over until some condition occurs? (A) block (B) array (C) loops (D) boolean (157) Which statement is executed if the value of Boolean expression is true?

If (boolean expression) { <statement1>

Compiled by Nuzhat Ibrahim Memon 9

} else { <statement2> }

(A) statement2 (B) error messsage (C) statement1 (D) statement3 (158) Which of the following statement is used to transfer the control outside ‘Switch’ or ‘Loop’ construct? (A) continue (B) else (C) end (D) break (159) Which of the following variable name is not valid in Java? (A)_marks (B) 4subject (C) total_marks (D) $age

Compiled by Nuzhat Ibrahim Memon 10

Textual Exercise (1) How many basic (primitive) data types are supported in Java ? (A)2 (B) 4 (C) 8 (D) 16 (2) What is the default data type of floating point literal? (A)Int (B) long (C) float (D) double (3) Which character set is used for char data type in java? (A)Unicode (B) ASCII (C) EBCIDIC (D) All of these (4) Which of the following is compiled error free? (A)for(;;){int i=7}; (B) while (1) { int i=7}; (C) while (true){int i=7} (D) All of these (5) Which of the following is not allowed as first character in valid variable name? (A)underscore(_) (B) digit (C) letter (D) dollar($) (6) Which of the following is not a basic data type in java? (A)Char (B) long (C) byte (D) String (7) What is the default value of Boolean type data? (A)null (B) true (C) false (D) 0 (8) What will be the result of arithmetic expression 7/2? (A)3 (B) 3.5 (C) 1 (D) 0 (9) What will be the result of arithmetic expression -7%2? (A)-3 (B) -1 (C) 1 (D) -3.5 (10) What will be the result of arithmetic expression -7.5%2? (A)-3 (B) -1.5 (C) 1.5 (D) Error Std. 12 (General) | March – 2015 (11) What sign is used for creating API documentation from the code ? (A) // (B)/*….*/ (C)/**…. */ (D) \\ (12)In Java. Which of the following looping is exit controlled? (A) for (B) while (C) do….while (D) if….then…else (13)In java, which of the following is not allowed as first character in valid variable name? (A)_(underscore) (B) digit (C) letter (D) $ (Dollar) (14) What is known as when program written in Java are compiled in to machine language for a computer ? (A) Java Visible Machine (B) Java Virtual Machine (C) Java View Modifier (D) Java Visible Modifier (15) What is known as post decrement in java when operator is used after variable name ? (A) ++ (B) - - (C) = = (D) =< (16) By using which extension file java interpreter byte code executes ? (A) .java (B) .class (C) .txt (D) .html (17) In Java, which statement is used when there are many alternative actions to be taken depending upon the value of a variable or expression? (A) Switch (B) Nested if (C) Control (D) Repeat (18) What kind of primitive data types are provided in Java from the following? (A) boolean (B) double (C) char (D) All of these (19) What is the value of float data type in Java ? (A) Integer (B) Real (C) Character (D) Boolean (20) what will be the result of arithmetic expression -7.5%2? (A)-3 (B) -1.5 (C) 1.5 (D) Error

Chapter 7 Java Basics Answer Key - Previous Years’ Board Paper Weightage 10 marks

Compiled by Nuzhat Ibrahim Memon 11

Std. 12 (Science) | March – 2015 (21)Java language is developed by which company ? (A) Sun Microsystem (B) Sun Java System (C) Sun System (D) Sun Microsoft (22)The machine language for the Java Virtual Machine is called what? (A) code byte (B) Type code (C) Java Bytecode (D) Java Code (23) While creating Java what must be the same ? (A) folder name, filename (B) class name, extension (C) class name, folder name (D) class name, file name (24) When the program gets compiled without error, compiler creates a file with which extension ? (A) .comp (B) .txt (C) .java (D) .class (25) The process of compiling and executing a java application is as follows. What is missing from given chart ? Java Source file(.java)java compiler (javac) ? JVM- Java Interpreter (java) (A) Java class(*.exe) (B) Java typecode (*.obj) (C)Java Bytecode (*.class) (D) Java typecode (*.obj) (26) Which of the following is right way to define variable ? (A) $age (B) discount rate (C) 4youpeople (D) %discount (27) String literals is a sequence of characters enclosed in which quotes ? (A) ‘ ‘ (B) “ “ (C) () (D) {} Std. 12 (General) | March – 2015 (27)Which of the two symbols are used in the conditional operator in Java ? (A) : and * (B) # and ? (C) ?and : (D) / and ? (29) While using shorthand version of assignment, it is defined as a+=b where a is 7 and b is 8 then what will result of a ? (A) 8 (B) 49 (C) 14 (D) 15 (30) When two operators are having different priority, then an operator with higher precedence is operate________

(A) first (B) last (C) second (D) middle (31)What will be output of following program? class abc{ public static void main(string[] S){ for(int i=0;i<10;i++){ SYSTEM.out.println(i); } } }

(A) error (B) i (C) Display 1 to 10 (D) 1,2,3,…….10 (32) Control structure branches are used to choose among two or more possible courses of action, is called as what ? (A) More structure (B) Loop structure (C) Addition structure (D) Selective structure (33) Switch statement can be stopped using which statement ? (A) break (B) run (C) loop (D) error (34) do ….. while loop is which type of loop ? (A) Loop controlled (B) Break controlled (C) Exit controlled (D) Entry controlled (35) To use a labeled loop, which symbol is added before the loop? (A) * (B) $ (C) : (D) # (36)in java, the text written in /*….*/ is considered as what ? (A) Method (B) Comment (C) Function (D) Variable (37) user can create Java source file by using ____________ application? (A) Scite Editor (B) ASCII text editor (C)Both (A) & (B) (D) None of these (38) The definition of the method (function) in java consists of function heard and the sequence of statement

enclosed in which bracket? (A) {} (B) <> (C)() (D) []

Compiled by Nuzhat Ibrahim Memon 12

(39) Java supports how many primitive data types ? (B) 3 (B) 8 (C) 4 (D) 7

(40) Which of the following data type is used for real numbers? (A) short (B) char (C) long (D) double Std. 12 (General) | March – 2016 (41) From the following which is considered as one of the ideal language for distributing executable program and also general purpose programming language for developing programs that are easily usable and portable across different platforms? (A) c language (B) java (C) visual basic (D) Javascript (42) Which extension is used to source file of java language, written in a text editor? (A) .class (B) .html (C) .jpg (D) .java (43) From the following which methods are used to display results? (A) system.out.print() (B) system.out.println() (C) Both (A) & (B) (D) system.out.display() (44) In java, the program is compiled without any error, which command is used to execute it? (A) ToolsGo (B) ToolsRun (C) ToolsBuild (D) ToolsCompile (45)How many primitive data types are there in Java? (A) 5 (B) 6 (C) 7 (D) 8 (46) From the following which are the examples of reserved words in Java? (A) class (B) public (C) static (D) All of these (47) A name used for a constant value is known as what in Java ? (A) String (B) Array (C) Literal (D) Class (48)Which sign is used to insert single line comment in Java? (A) /* and */ (B) /** and */ (C) // (D) # (49)From the following which is not logical operator in Java? (A) AND (B) OR (C) NOT (D) Equal to (50)From the following which is true syntax of conditional operator? (A) <exp>=<exp>=<expr> (B) <exp>?<exp>:<expr> (C) <exp>;<exp>?<expr> (D) <exp>=<exp>:<expr> Std. 12 (Science) | March – 2016 (51)In java, at which level platform –independence is possible due to bytecode interpreter? (A) browser (B) source (C) machine (D) binary (52)in Java, the machine language for Java Virtual Machine is known as which code? (A) javafilecode (B) java bytecode (C) java intcode (D) java sourcecode (53)To compile the java program we have to type what in front of source filename? (A) javac filename.java (B) javac filename (C) javac filename.html (D) java filename.java (54) In Java program is compiled without any error we can execute it in SciTE editor by which menu-option? (A) compileRunGo (B) EditGo (C) ToolsGo (D) FileGo (55)Java supports how many primitive data types? (A) 2 (B) 4 (C) 6 (D) 8 (56) What is the storage space for datatype float in java? (A) 1 byte (B) 2 byte (C) 4 byte (D) 8 byte (57)Real numbers in Java are compliant with which of the following? (A) IEE 36 (B) IEE 16 (C) IEEE 780 (D) IEEE 754 (58) In java, variable name should begin with which of the following? (A) alphabet (B) underscore(_) (C) Dollar sign (D) All of these (59) In java, a name used for constant value is known as what? (A) string return (B) Literal (C) Unicode Quote (D) ASCII

Compiled by Nuzhat Ibrahim Memon 13

(60) Java 7 also supports binary numbers, using digits 0 and 1 but it should be prefix by which of the following? (A) 0b or 0B (B) B (C)B1 (D) b0 (61)In java, for type booleanthere are precisely two literals, which are they? (A) Y or N (B) 0 and 1 (C) True or False (D) Yes or No (62) in Java, characters are stored by how many bit Unicode characters? (A) 4-bit (B) 8-bit (C) 16-bit (D) 32 bit (63)String literals in java is a sequence of characters which can be enclosed in which of the following? (A) $...$ (B) “ “ (C) ‘ ’ (D) `` (64)In java, documentation comments begins and ends with which of the following ? (A) /**…*/ (B) /*….*/ (C) /*…/ (D) // (65)Arithmetic operators in java, can be applied on which numeric data? (A) short (B) float (C) byte (D) all of these (66)In java, which of the following is known as unary operators for increment and decrement operators? (A) >== and <= (B) + and - (C) == and != (D) ++ and - - (67)Which of the following is considered as comparison operator in Java? (A) = (B) / (C) % (D) != (68) In java,logical operators are also called which of the following operators if they operate on Boolean operands? (A) assignment operator (B) Boolean operator (C) Increment operator (D) Relational operator (69)In java, conditional uses which two symbols in expression to delimit three operands? (A) ?and * (B) . and : (C) ? and : (D) : and ; (70)In Java, a block statement is a group of statements enclosed between which pairs of braces? (A)[/…../] (B) {} (C) () (D) [] Std. 12 (General) | March – 2017 (71) Java language was developed by whom? (A) Sun Microsystem (B) Oracle (C) Netscape (D) Microsoft (72) When java program created java source file using text editor, which file extension should be given? (A) .class (B) .html (C) .obj (D) .java (73) What is the full form of JVM? (A) Java Visibility Machine (B) Java Visual Machine (C) Java Virtual Machine (D) Java Vocal Machine (74) Which menu-option is used to compile source program to SciTE? (A) EditCompile (B) FormatCompile (C) ToolsCompile (D) FileCompile (75) What is the default value of boolean data type of java? (A) False (B) True (C) 0 (D) 1 (76) From the following which is the illegal name of variable in java? (A) 4me (B) result (C) amount$ (D) price$ (77) The name used for a constant value is known as what in java? (A) String (B) Array (C) Literal (D) class (78)which sign indicates single line comment in Java? (A) /*…*/ (B) /**…*/ (C) // (D) # (79) From the following which is not a comparison operator in java? (A)> (B) < (C) >= (D) + (80) Which operator can be used to concatenate a string in java? (A)= (B) + (C) & (D) * Std. 12 (Science) | March – 2017 (81) Which of the Java syntax is very similar to which language? (A)Fortran (B) SQL (C) C (D) FoxPro

Compiled by Nuzhat Ibrahim Memon 14

(82) At which level platform-independence is possible due to bytecode interpreter? (A) Bottom level (B) Binary level (C) Source level (D) High level (83)The alphabet D in JDK stands for which of the following? (A) Department (B) Development (C) Design (D) Desktop (84) Which of the following company is best known for its high-end unix workstations? (A) Sun Microsoft (B) Sun Microchip (C) Sun Microsystems (D) Sun Microsource (85) Programs written in Java are compiled into machine language for a computer that doesn’t really exists. This type

of computer is known as what? (A) Java Virtual Model (B) Java verifier Machine (C)Java Vertical Machine (D) Java Virtual Machine (86) The only disadvantage of using bytecode is which of the following ? (A) High execution speed (B) Fast execution speed (C) Slow execution speed (D) Random execution speed (87) In java, java source files name and class they define name should be what? (A)Totally different (B) Same (C) Different (D) vice versa (88) What is the extension of java source file? (A) .j (B) .java (C) .class (D) .jav (89) Which of the following way user can run “abc.java” source program through the application using java

interpreter? (A) java ABC (B) java abc.obj (C) java abc.class (D) java abc (90) In java, the text written in which of the following are comments? (A) \*…\* (B) /*….*/ (C) /*…*\ (D) \*….*/ (91) Which of the following editor is used to create java source program in ubuntu? (A) Jedit (B) Notebook (C) Workpad (D) SciTE (92) Java consists of function header and the sequence of statements enclosed between which braces? (A) <> (B) [] (C) {} (D) () (93) Java supports how many primitive data types ?

(B) 6 (B) 7 (C) 8 (D) 9 (94) Which of the following data type is hold real numbers?

(A) long (B) double (C) char (D) byte (95) A name used to refer to the data stored in memory is called what? (A) value (B) object (C) variable (D) function (96) Which of the following is illegal way to define variable name in Java? (A) $price (B) %sale (C) B4U (D) Amount$ (97) Which of the following is not reserved word in java? (A) class (B) else (C) static (D) rate (98) Control structures in Java is divided into two types: Loops and what? (A) Message (B) Function (C) Branches (D) Alerts (99) In java, which statement is used to exit from the loop structure? (A) stop (B) exit (C) out (D) break (100) Which of the following is exit-controlled loop in java? (A) for (B) do…while (C) while (D) loop Std. 12 (General) | March – 2018 (101) When the program gets compiled without errors, compiler created which type of file extension in java? (A) .class (B) .java (C) .c++ (D) .c (102) From the following which is not compiled or interpreted in Java? (A) if statement (B) function (C) comment (D) variable (103) Whichcommand is used if the program is compiled without any error? (A) ToolsExecute (B) EditGo (C) ToolsGo (D) Toolscompile

Compiled by Nuzhat Ibrahim Memon 15

(104) In java, Boolean data type hold which logical values? (A) Y,N (B) 0,1 (C) True, False (D) Yes, No (105) From the following which legal name of variable ? (A) birth date (B) birth_date (C) %discount (D) 4balance (106) Which numeric digits are used for hexadecimal numbers (16 digits) in integer literals in Java? (A) 0 to 8 and A to F (B) 0 to 9 and A to F (C) 0 to 15 (D) 0 to 16 (107) What is the symbol for multi-line comment in Java program? (A) /*…*/ (B) //*…*// (C) *….* (D) // (108) In Java, what will be the result of arithmetic expression 8%3? (A) 8 (B) 3 (C) 4 (D) 2 (109) Whichsign is used for “A not equal to B” in comparison operator of java? (A) A≠B (B) A!=B (C) A not equal B (D) A==B Std. 12 (Science) | March – 2018 (110) Which of the following statement is true for java language? (i) Java language was developed by sun microsystem (ii) Java is an object oriented language (iii)Java is not platform-independent at both the source and binary level (A) only (i) and (ii) (B) only (ii) and (iii) (C) only (i) and (iii) (D) (i), (ii) and (iii) (111) In java, float data type takes how many bytes of storage space? (A) 2 bytes (B) 4 bytes (C) 8 bytes (D) 16 bytes (112) In java, variable name must begin with which of the following? (A) alphabet (B) digit (C) spaces (D) % (113) Which of the following statement is right for Boolean literal in Java?

(i) 0 is treated as false and 1 is treated as true (ii) Literals are to be typed without quotes (iii) For the Boolean type, there are two literals:true and false

(A) (i),(ii) and (iii) (B) only (ii) and (iii) (C) only (i) and (iii) (D) only (i) and (ii) (114) Which of the following is not a basic arithmetic operator of Java? (A) \ (B) - (C) * (D) + (115) Which of the following is not a comparison operator in Java ? (A) != (B) >= (C) = (D) <= (116) How many types of control structures are there in Java? (A) Four (B) Two (C) Three (D) one (117)In the switch statement of java, the test expression should be of which of the following type? (A) boolean (B) double (C) byte (D) float (118) Injva, which of the following loop is exit-controlled or post-test loop construct? (A) switch (B) while loop (C) do….while loop (D) for loop (119) After execution of which statement in the loop of java, all the following statements in a body of the loop are

skipped and no further iteration take place? (A) loop (B) go (C) break (D) continue

Std. 12 (General) | March – 2019 (120) In Java, What is the default value of Boolean type data? (B) True (B) false (C) 1 (D) 0

(121) In java, which of the following is used to repeat a sequence of statements over and over until some condition occurs?

(A) Loops (B) Branches (C) Breaks (D) Sets (122) Java supports how many primitive data types ? (B) 2 (B) 4 (C) 6 (D) 8

Compiled by Nuzhat Ibrahim Memon 16

(123) Who developed Java language? (A) Microsoft (B) Adobe (C) Google (D) Sun Microsystems (124) What is the machine language for the Java Virtual Machine known as? (A) Java source code (B) java application code (C) Java program code (D) Java byte code (125) in SciTE editor, which menu-option is used to compile java source program? (A) ToolsGo (B) Toolscompile (C) Toolsbuidcode (D) FileRun (126) Which of the following is not used for comment in Java? (A) // (B) /*….*/ (C) //*….*// (D) /**…..*/ (127) What should be the extension of java source program file? (A) .class (B).jar (C) .htm (D) .java (128) Which of the following is a comparison operator of java? (A) + (B) % (C) < (D) * (129) In Java, which statement is used to skip the following statements in a loop and continue with next iteration ? (A) break (B) continue (C) go (D) run Std. 12 (Science) | March – 2019 (130) Where java language developed? (A) Apple systems (B) SON Microsystems (C) Oracle systems (D) Sun Microsystems (131) Whatis the full form of JVM? (A) Java Vertical Machine (B) Java Virtual Machine (C) Java Varity Machine (D) Java Visual Machine (132) Which of the following editor is used to create java file in ubuntu? (A) Calc (B) Writer (C) Scite (D) Wordpad (133) Which of the following is right when java file is created? (A) Java source file & class name must be different (B) Java source file & class name must be same (C) Name must start with Number ‘2’ only (D) Name must have symbol ‘$’ at the end (134) Which of the following is comment statement in Java? (A) /#....#/ (B) \*…*\ (C) /*…..*/ (D) /*…../* (135) Which of the following command is given in JDK using java interpreter? (A) Run Call Cost (B) javarc Call Cost (C) Java Call Cost (D) JavaRun Call Cost (136) Which of the following is missing from compilation process to execute java application ?

(A) Java Bitecodefile(*.csc) (B) Java Bytecode file (*.class) (C) Java Bookcodefile(*.cla) (D) JavaCompilercode(*.javacr) (137) How many basic (primitive) data types are supported in java? (A) .4 (B) 2 (C) 8 (D) 16 (138) Which of the following escape code is used for backspace in java? (A) \t (B) \n (C) \b (D) \k

JVM-Java Interpreter(Java)

Java Compiler (Javac)

Java Source File (usually have extension.java)

Compiled by Nuzhat Ibrahim Memon 17

(139) which of the following loop is exit controlled loop in java? (A) .do…while (B) for (C) for…while (D)exit….while Std. 12 (General) | March – 2020 (140) How many basic (primitive) data types are supported in Java ? (A) 2 (B) 4 (C) 8 (D) 16

(141) In switch statement, if no match is found between test expression and case values, then which statement will be executed?

(A) break (B) continue (C) if…else (D) default (142) If a=12.5 and b=7.2, then after executing a%b, what will be the remainder?

(A) 1 (B) 5.3 (C) 5.0 (D) 1.22 (143) When a variable is declared inside a block, what is it called?

(A) Global (B) Local (C) Label (D) Repetitive (144) Which of the following is a proper option for the statement “Is A not equal to B”?

(A) A <> B (B) A ≠ B (C) A NOT B (D) A!= B (145) If the conditional ternary is next = (N%2==0)?(N/2):(3*N+1); where N=7 then what will be the value of variable next?

(A) 22 (B) 7 (C) 3.5 (D) 0 (146) Which symbol is used to begin single line comment?

(A) /* … */ (B) /** …. */ (C) // (D) \\ (147) By using which of the following statements the following statements in a body of the loop are skipped and control is transferred at the first statement after the switch statement?

(A) continue (B) default (C) break (D) for (148) Which logical operator returns true only if its operands are different (one true and one false) and false otherwise?

(A) XOR (B) OR (C) AND (D) NOT (149) Which of the following is not a proper example of Hexa decimal number? (A) OXFF7A (B) OX39A2 (C) OX532D (D) OABC Std. 12 (Science) | March – 2020 (150) How many primitive data types are supported in Java ? (B) 2 (B) 4 (C) 8 (D) 16

(151) Java language was developed by which of the following company? (A) Sun Microsystem (B) Netscape (C) Microsoft (D) Oracle (152) Which of the following extension file is generated by compiler, when the program gets compiled without error in java ? (A) .java (B) .c (C) .org (D) .class (153) Single line comment begins with which sign in Java? (A) /* (B) // (C) /** (D) All of the above (154) What will be the result of arithmetic experssin 9%2 ? (A) 4.5 (B) 1 (C) 4 (D) 0 (155) What is it called when ++ operator is used after variable name in Java? (A) post increment (B) pre increment (C) increment pre (D) pre decrement (156) Which of the following is used to repeat a sequence of statements over and over until some condition occurs? (A) block (B) array (C) loops (D) boolean (157) Which statement is executed if the value of Boolean expression is true?

If (boolean expression) { <statement1>

Compiled by Nuzhat Ibrahim Memon 18

} else { <statement2> }

(A) statement2 (B) error messsage (C) statement1 (D) statement3 (158) Which of the following statement is used to transfer the control outside ‘Switch’ or ‘Loop’ construct? (A) continue (B) else (C) end (D) break (159) Which of the following variable name is not valid in Java? (A)_marks (B) 4subject (C) total_marks (D) $age