MULTIPLE CHOICE QUESTIONS (MCQs) - CH NO. 7: JAVA BASICS (XII GSEB) WITH SOLUTIONS

GUJARAT SECONDARY & HIGHER EDUCATION BOARD
SUBJECT: INTRODUCTION TO COMPUTERS
CHAPTER-7: JAVA BASICS
MCQS WITH ANSWER.

(1)               Java is an object oriented programming language developed by ..................
(a) Sun Macromedia     (b) Sun Microsystems  (c) Sun Multimedia        (d) Sun systems
(2)               Most of the java .................. is/are very similar to C Language.
(a) Coding                      (b) Logic                        (c) Syntax                      (d) Operators
(3)               Java Language was developed in the year ..................
(a) 1990                         (b) 1991                         (c) 1992                         (d) 1993
(4)               .................. language is considered to be the ideal language for distributing the executable programs via the World Wide Web.
(a) C                               (b) VB.Net                      (c) Java                          (d) All of these
(5)               Java is .................. language.
(a) a Procedural Structure                                   (b) an Object Oriented Programming     

(c) a Hierarchy Structure                                     (d) All of these
(6)               In java, .................. provides the basic data types, system inputs and output capabilities.
(a) packages                  (b) class libraries          (c) Both (a) & (b)           (d) None of these
(7)               The basic class libraries of java are the part of ..................
(a) jre                             (b) jsp                            (c) jdk                            (d) jps
(8)               Java programming language is the platform .................., which provides the capability of being moved easily from one computer system to another.
(a) dependent                (b) independent           (c) relevant                    (d) irrelevant
(9)               At binary level, java platform independence is possible due to .................. interpreter.
(a) Developer                (b) Bytecode                 (c) Java Interpreter       (d) Compiler
(10)           Program written in Java are compiled into machine language for a compute that doesn’t really exist; which is known as ..................
(a) JSP                            (b) JRE                           (c) JDK                            (d) JVM
(11)           The advantage of Bytecode of Java is ..................
(a) It is not specific to any processor                  (b) It is not specific to any operating sytem

(c) Both (a) & (b)                                                (d) None of these
(12)           The disadvantage(s) of Bytecode of Java is: ..................
(a) Its slow execution speed                              (b) its compiler is too slow

(c) It is not user friendly                                      (d) All of these
(13)           A java program is composed of ..................
(a) methods                   (b) classes                     (c) objects                      (d) variables
(14)           At least one class of java program must have the ..................method.
(a) main                         (b) java                          (c) parent                       (d) common
(15)           .................. is not available in java, which is available in C programming.
(a) derivedtype              (b) typedef                   (c) user defined type     (d) All of these
(16)           ................. name(s) are case sensitive in Java programming.
(a) class                         (b) file                            (c) Both (a) & (b)          (d) None of these
(17)           The extension of java programming language file is ..................
(a) .jar                            (b) .java                         (c) .jsp                            (d) .jp
(18)           The java program can be compiled using the .................. compile command.
(a) java                          (b) javac                        (c) compile                    (d) javax
(19)           Using JDK, the Java interpreter (.class file) is simply called using .................. command.
(a) java                          (b) javac                        (c) compile                    (d) javax
(20)           The class access specifier of the main method class should always be ..................
(a) public                       (b) private                     (c) protected                  (d) None of these
(21)           If we don’t write any access specifier/ before the class name in java, it is considered to be ................. by default.
(a) public                       (b) private                     (c) protected                  (d) None of these
(22)           In Java, .................. is the first routine that is run when the program is executed.
(a) main                         (b) class                         (c) parent                       (d) common
(23)           The extension of the bytecode file of java is ..................
(a) .bcd                          (b) .java                         (c) .class                         (d) .bcod
(24)           The .java extension is refers to ..................
(a) Java Compiler          (b) Java Source File      (c) Java Bytecode File    (d) Java Interpreter
(25)           The .class extension is refers to ..................
(a) Java Compiler          (b) Java Source File       (c) Java Bytecode File  (d) Java Interpreter
(26)           The javac command is refers to ..................
(a) Java Compiler         (b) Java Source File       (c) Java Bytecode File    (d) Java Interpreter
(27)           The java command is refers to ..................
(a) Java Compiler          (b) Java Source File       (c) Java Bytecode File    (d) Java Interpreter
(28)           .................. are not compiled or interpreted in Java programming.
(a) Markers                   (b) Indicators                 (c) Comments               (d) Bookmarks
(29)           The .................. command(s) takes the values to be displayed as an argument and prints the result on the screen.
(a) System.out.print       (b) System.out.println   (c) Both (a) & (b)          (d) None of these
(30)           The .................. command adds a linefeed after the end of the information that it displays the results on the screen.
(a) System.out.print       (b) System.out.println (c) Both (a) & (b)           (d) None of these
(31)           The word ‘public’ before any method in program means ..................
(a) function can be called inside the program    (b) function can be called outside the program

(c) Both (a) & (b)                                                 (d) None of these
(32)           Using .................. editor Java application can be created.
(a) SciTE                         (b) Notepad++               (c) PSPad                        (d) All of these
(33)           Using SciTE, java programming can be compiled from .................. menu.
(a) Run                           (b) Edit                           (c) Tools                        (d) Compile
(34)           Using SciTE, java program can be executed from .................. menu.
(a) Run                           (b) Edit                           (c) Tools                        (d) Compile
(35)           Java program can be compiled from .................. menu using SciTE.
(a) ToolsàCompile      (b) CompileàCompile  (c) FileàCompile          (d) RunàCompile
(36)           Java program can be executed from .................. menu using SciTE.
(a) ToolsàGo               (b) CompileàGo           (c) FileàGo                   (d) RunàGo
(37)           The rules of the programming languages are determined that what is allowed; and these rules are called .................. of the language.
(a) Rules                        (b) Syntax                     (c) Grammar                 (d) Design
(38)           Java is a ................. language, in context to formatting of instructions.
(a) free format            (b) case format           (c) rigid format           (d) formatting
(39)           Which of the following statement is correct in context to methods in java?
(a) A method in java can be written anywhere in the program.              

(b) A method can always be private in the program.                               
(c) A method can’t exist by itself; it has to be part of a class.              
(d) A method can’t be overloaded.

(40)           Which of the following statement(s) is/are correct in context to layout of Java program?
(a) The compiler of java doesn’t care about the program layout.            

(b) We can write an entire program together in a single line also          
(c) Both (a) & (b)          
(d) None of these

(41)           .................. determines the required memory size, range of values that can be performed in java program.
(a) Variables                  (b) Literals                     (c) Data Types               (d) Comments
(42)           Which of the following statement(s) is/are correct in context to Data type(s) in Java?
(a) It determines the required memory size.

(b) It determines the range of values.
(c) It determines the types of operations that can be performed. 
(d) All of these

(43)           Java supports the .................. primitive data types.
(a) seven                        (b) eight                        (c) nine                          (d) ten
(44)           There are .................. number of data types in java that can hold the integer numbers.
(a) two                           (b) three                        (c) four                          (d) five
(45)           Which of the following data types is not an integer type?
(a) byte                          (b) int                             (c) long                          (d) None of these
(46)           Which of the following data types is an integer type?
(a) short                        (b) float                         (c) double                      (d) None of these
(47)           There are .................. number of data types in java that can hold the real numbers.
(a) two                          (b) three                        (c) four                           (d) five
(48)           Which of the following data types is not an real type?
(a) float                          (b) long                         (c) double                      (d) None of these
(49)           ‘char ‘ data types holds a single character from the.................. character set.
(a) ASCII Code                (b) Unicode                   (c) Both (a) & (b)           (d) None of these
(50)           .................. data type holds one of the two logical values; true or false.
(a) logical                      (b) boolean                   (c) Both (a) & (b)           (d) None of these
(51)           The built in data types of java are also called .................. data types.
(a) class defined            (b) pre-defined              (c) primitive                  (d) user defined
(52)           The primitive data types are ..................
(a) machine independent                                  (b) machine dependent      

(c) Both (a) & (b)                                                 (d) None of these
(53)           Choose the correct option for “Match the following”; data types with their respective sizes.

(A) byte           :           i)          4 Bytes
(B) short          :           ii)         2 Bytes
(C) float           :           iii)        8 Bytes
(D) double       :           iv)        1 Byte
(a) A-iv, B-ii, C-I, D-iii    (b) A-iii, B-iv, C-I, D-ii    (c) A-ii, B-iv, C-I, D-iii    (d) None of these
(54)           Choose the correct option for “Match the following”; data types with their respective range.
(A) byte           :           i)          -32768 to 32767
(B) short          :           ii)         -92233720368775808 to 92233720368775807
(C) int  :           iii)        -128 to 127
(D) long           :           iv)        -2147483648 to 2147483647
(a) A-iv, B-ii, C-I, D-iii          (b) A-iii, B-i, C-Iv, D-ii       (c) A-ii, B-i, C-Iv, D-iii          (d) None of these
(55)           The ‘char’ data type has the .................. range of values
(a) 4 bits Unicode character                                (b) 8 bits Unicode character          

(c) 16 bits Unicode character                            (d) None of these
(56)           Real numbers in Java are complaint with .................. standard.
(a) ANSI                          (b) IEEE 754                   (c) ASCII                         (d) All of these
(57)           A name use to refer the data stored in computer memory is called a ..................
(a) Literal                       (b) Data Type                (c) Variable                   (d) Comment
(58)           Which of the following is correct; in context to Variables in Java?
(a) Its name should not start with a numerical value.

(b) It should not contain space in its name.
(c) Its name should not be a reserved word of Java.
(d) All of these

(59)           The syntax for the declaration the variable in java is ..................
(a) <type-name> {variable-names};                  (b) <variable-names> {type-name};           

(c) Both (a) & (b)                                                 (d) None of these
(60)           Which of the following is the valid variable name in java?
(a) India@1947              (b) 1947_India               (c) India 1947                (d) None of these
(61)           Which of the following is the reserved word of java?
(a) public                       (b) static                        (c) void                           (d) All of these
(62)           Which of the following is the valid variable name in java?
(a) Void                          (b) Public                       (c) Static                        (d) All of these
(63)           Which of the following is the invalid variable name in Java?
(a) birth date                (b) dob                           (c) Both (a) & (b)           (d) None of these
(64)           Which of the following is the valid variable name in Java?
(a) birth date                 (b) dob                          (c) Both (a) & (b)           (d) None of these
(65)           In java, there are .................. kinds of variables.
(a) two                           (b) three                       (c) four                           (d) five
(66)           Which of the following is not a kind of variable in Java?
(a) Instance Variable     (b) Local Variable          (c) Class Variable          (d) None of these
(67)           The .................. variables are not initialized with values in Java.
(a) Instance                    (b) Local                        (c) Class                         (d) None of these
(68)           A name used for a constant value is known as ..................
(a) Literal                      (b) Data Type                (c) Variable                    (d) Comment
(69)           Numeric literals are used to represent .................. or ................. numbers.
(a) integer, short           (b) float, double            (c) integer, real             (d) None of these
(70)           In java, .................. literals are whole numbers.
(a) Real                          (b) Integer                    (c) String                        (d) All of these
(71)           Which of the following literals are allowed by Java?.
(a) decimal (base 10)    (b) binary (base 2)         (c) Both (a) & (b)           (d) None of these
(72)           A user can force a smaller number to be a long by appending an ................. as a suffix to the number.
(a) L or l                         (b) N or n                       (c) H or h                       (d) F or f
(73)           In Java, a numeric literal with a leading 0 (zero) is interpreted as an ................. number.
(a) Binary                       (b) Octal                        (c) Hexadecimal            (d) Decimal
(74)           In Java, a numeric literal with a leading 0x or 0X is interpreted as an ................. number.
(a) Binary                       (b) Octal                        (c) Hexadecimal            (d) Decimal
(75)           Which of the following literals is an integer literal?
(a) 054                           (b) 54                             (c) 0x54                          (d) 54.0
(76)           Which of the following literals is real literal?
(a) 054                           (b) 54                             (c) 0x54                          (d) 54.0
(77)           Which of the following literals is an octal number literal?
(a) 054                           (b) 54                             (c) 0x54                          (d) 54.0
(78)           Which of the following literals is Hexadecimal number literal?
(a) 054                           (b) 54                             (c) 0x54                          (d) 54.0
(79)           Which of the following scientific notation number is correct in Java?
(a) 1.3E12                      (b) 13E.12                      (c) .13.E12                     (d) None of these
(80)           In Java, scientific format can be used to express the ..................
(a) very large numbers (b) very small numbers (c) Both (a) & (b)          (d) None of these
(81)           For the type boolean, there is/are precisely .................. literal(s) can be used.
(a) one                           (b) two                          (c) three                         (d) four
(82)           .................. literals are expressed by a single character surrounded by a single quote.
(a) Character                (b) String                       (c) Both (a) & (b)           (d) None of these
(83)           .................. literals are expressed by a group of character surrounded by a double quotes.
(a) Character                 (b) String                      (c) Both (a) & (b)           (d) None of these
(84)           Choose the correct option for “Match the following”; Escape code with their meanings.
(A) \n   :           i)          Carriage Return
(B) \t    :           ii)         New Line
(C) \b   :           iii)        Tab
(D) \r   :           iv)        Backspace
(a) A-iv, B-ii, C-I, D-iii    (b) A-iii, B-iv, C-I, D-ii    (c) A-ii, B-iii, C-iv, D-i    (d) None of these
(85)           Choose the correct option for “Match the following”; Data types with their Literals.
(A) int  :           i)          078
(B) double       :           ii)         78
(C) float           :           iii)        78.0
(D) Octal         :           iv)        78f
(a) A-iv, B-ii, C-I, D-iii    (b) A-iii, B-iv, C-I, D-ii    (c) A-ii, B-iii, C-iv, D-i    (d) None of these
(86)           In Java, String is the predefined .................. type.
(a) Primitive                  (b) Object                     (c) Data                          (d) Variable
(87)           The Unicode sequence \u2122 will produces a .................. symbol.
(a) Trade Mark (TM)      (b) Copyright ©             (c) Registered ®             (d) None of these
(88)           In Java, .................. comment starts with double slash( //) and extends till the end of line.
(a) Single Line               (b) Multi Line                (c) Documentation        (d) All of these
(89)           In Java, .................. comment begins with /* and ends with */.
(a) Single Line                (b) Multi Line               (c) Documentation        (d) All of these
(90)           In Java, .................. comment begins with /** and ends with */.
(a) Single Line                (b) Multi Line                (c) Documentation       (d) All of these
(91)           The basic building block of .................. are literals, variables and function calls.
(a) conditions                 (b) expressions             (c) comments                (d) operators
(92)           The variable name like “balanceAmount”, “bankBalance”, “callCost”, etc. used the upper case letter in the middle. What type of case of this name is referred in java?
(a) Sentence case          (b) Toggle Case             (c) Camel Case              (d) Giraffe Case
(93)           …………………… are special symbols used to build an expression in Java.
(a) Literals                     (b) Constants                 (c) Variables                  (d) Operators
(94)           Basic addition(+), subtraction(-), multiplication(*), division(/) and modulus(%)are   …………………… operators in java.
(a) Basic                         (b) Mathematic             (c) Arithmetic               (d) None of these
(95)           Which of the following operator can be used as unary operator also in Java?
(a) +                               (b) *                               (c) /                                (d) %
(96)           Which of the following operator cannot be used as unary operator also in Java?
(a) *                               (b) %                              (c) /                                (d) None of these
(97)           When lower range data type is implicitly converted to higher data type to have the  same type of operands. This type of conversion is also known as ……………………
(a) type conversion        (b) type casting             (c) promotion               (d) increment
(98)           Which of the following operator can  be used to concatenate a string in Java?
(a) +                               (b) *                               (c) %                               (d) None of these
(99)           The ++ operator is used before variable; e.g. ++a; is also termed as ……………………
(a) Post increment         (b) Pre increment        (c) Real Increment        (d) None of these
(100)       The ++ operator is used after variable; e.g. a++; is also termed as ……………………
(a) Post increment       (b) Pre increment          (c) Real Increment        (d) None of these
(101)       If the value of x = 5 and y= 4 + ++x; statement is termed. What will be the value of x and y?
(a) x will be 6, y will be 9                                    (b) x will be 6, y will be 10           

(c) x will be 5, y will be 9                                     (d) x will be 5, y will be 10
(102)       If the value of x = 5 and y= 4 + x++; statement is termed. What will be the value of x and y?
(a) x will be 6, y will be 9                                   (b) x will be 6, y will be 10 

(c) x will be 5, y will be 9                                     (d) x will be 5, y will be 10
(103)       When x++; or ++x; is used in a program, it is termed as ……………………  statement in java.
(a) standalone              (b) individual                 (c) single                        (d) binary
(104)       …………………… operators are also known as relational operators.
(a) Arithmetic                (b) Comparison            (c) Logical                      (d) None of these
(105)       Choose the correct option for “Match the following”; Comparison operators.
(A) A == B        :           i)          Is A “greater than or equal to” B?
(B) A >= B        :           ii)         Is A “less than” B?
(C) A < B          :           iii)        Is A “Not equals to” B?
(D) A != B        :           iv)        Is A “equals to” B?
(a) A-iv, B-i, C-ii, D-iii    (b) A-iii, B-iv, C-I, D-ii    (c) A-ii, B-iii, C-iv, D-i    (d) None of these
(106)       …………………… operators are also called Boolean operators.
(a) Comparison              (b) Logical                     (c) Arithmetic                (d) Relational
(107)       Choose the correct option for “Match the following”; Logical operators.
(A) AND           :           i)          ||
(B) OR :           ii)         ^
(C) NOT           :           iii)        &&
(D) XOR           :           iv)        !
(a) A-iii, B-ii, C-iv, D-i    (b) A-iii, B-i, C-iv, D-ii   (c) A-ii, B-iii, C-iv, D-i    (d) None of these
(108)       The conditional operator in java uses …………………… operands.
(a) two                           (b) three                       (c) four                           (d) None of these
(109)       Choose the correct option for “Match the following”;  Operators.
(A) && :           i)          Assignment Operator
(B) =    :           ii)         Increment Operator
(C) ++  :           iii)        Arithmetic Operator
(D) %   :           iv)        Logical Operator
(a) A-iv, B-i, C-ii, D-iii    (b) A-iii, B-iv, C-I, D-ii    (c) A-ii, B-iii, C-iv, D-i    (d) None of these
(110)       The conditional operator in java is also termed as …………………… operator.
(a) Unary                       (b) Binary                      (c) Ternary                    (d) None of these
(111)       “<variable><operator>=<expression>” (e.g. a+=b)is a syntax of …………………… operator.
(a) Assignment              (b) Shorthand              (c) Conditional               (d) None of these
(112)       …………………… refers to conversion of the data type manually that wouldn’t done automatically in java.
(a) Type conversion       (b) Type casting           (c) Promotion                (d) Increment
(113)       The syntax of the type casting is: ……………………
(a) (<data type>) <expression>                         (b) <variable name> <expression>            

(c) (<data type>) <variable name>                     (d) None of these
(114)       When two operators are having different priority, then with the …………………… precedence is operated first.
(a) lower                        (b) higher                      (c) equality                    (d) None of these
(115)       Precedence rule can be explicitly overridden by explicit ……………………
(a) operator                   (b) parenthesis             (c) statement                 (d) None of these.
(116)       There are …………………… types of control structures in Java.
(a) two                          (b) three                        (c) four                           (d) five
(117)       …………………… are used to repeat a sequence of statements over and over until same condition occurs.
(a) Switch Statements   (b) Loops                       (c) If Statements            (d) None of these
(118)       A …………………… statement is a group of statements enclosed between a pair of braces, “{“ and “}”.
(a) Control Structure     (b) Block                       (c) Method                     (d) None of these
(119)       A variable declare insider a block, they are termed as …………………… variables.
(a) Local                        (b) Class                         (c) Instance                    (d) Global
(120)       The …………………… statement when used in a program enables to take one of two alternatives courses of action depending on whether the value of a given Boolean values expression is true or false.
(a) switch                       (b) if                              (c) for                             (d) None  of these
(121)       When if statement is executed, it first evaluates …………………… expression.
(a) integer                     (b) boolean                   (c) character                  (d) None of these
(122)       …………………… statement is used when there are many alternative actions to be taken depending upon the value of a variable or expression.
(a) if                               (b) switch                      (c) for                             (d) None of these
(123)       The switch statement, the test expression should be the …………………… data type only.
(a) int                             (b) char                          (c) byte                          (d) All of these
(124)       The …………………… statement is used to transfer the control outside switch or loop structure.
(a) end                           (b) break                       (c) continue                   (d) None of these
(125)       The …………………… statement is used tos kip the following statements in a loop and continue with the next iteration.
(a) end                           (b) break                        (c) continue                  (d) None of these
(126)       When a loop is used inside a loop is termed as …………………… loop.
(a) structured                (b) labeled                     (c) Nested                     (d) Multiple
(127)       The label can be added in java program using …………………… symbol.
(a) ; (semi colon)           (b) . (period)                  (c) : (colon)                   (d) None of these
(128)       How many basic data types are supported in Java?
(a) 2                               (b) 4                               (c) 8                               (d) 16
(129)       What is the default data type of floating point literal?
(a) int                             (b) long                          (c) float                          (d) double
(130)       Which character set is used  for char data type in Java?
(a) Unicode                   (b) ASCII                         (c) EBCIDIC                    (d) All of these
(131)       Which of the following is compiled error free?
(a) for(;;0 {int i=7};        (b) while(1){int i=7};      (c) while(True) {int i=7};     (d) All of these
(132)       Which of the following is not allowed as first character in valid variable name?
(a) Underscore(_)          (b) Digit                         (c) Letter                        (d) Dollar ($)
(133)       Which of the following is not a basic data type in Java?
(a) char                          (b) long                          (c) byte                          (d) String
(134)       What is the default value of Boolean type data?
(a) null                           (b) true                          (c) false                          (d) 0
(135)       What will be the result of arithmetic  expression of 7/2?
(a) 3     (b) 3.5  (c) 1     (d) 0
(136)       What will be the result of arithmetic expression %-7/2?
(a) -3                              (b) -1                             (c) -3.5                           (d) 1
(137)       What will be the result of arithmetic expression -7.5%2?
(a) -3                              (b) -3.5                          (c) 1.5                            (d) Error

No comments

Post your comments

Powered by Blogger.