Compiled by Nuzhat Memon
CHAPTER 7
JAVA BASICS
Important MCQs
Compiled by Nuzhat Memon
Important MCQs :
1. 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
2. Java was developed by which company in 1991?
a) Sun Microsystems
b) ABM
c) Microsoft
d) Apple 2
Compiled by Nuzhat Memon
3. Which of the Java syntax is very similar to which language?
a) C
b) Fortan
c) SQL
d) FoxPro
4. 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) 3
Compiled by Nuzhat Memon
4
5. In java, who provides basic data types, system I/O capabilities and other
utility functions?
a) JDK
b) JVM
c) Class libraries
d) UML
6. Basic classes are part of the __________
a) JDK
b) JVM
c) UML
d) OML
Compiled by Nuzhat Memon
5
7. Who have classes to support networking, common Internet protocols and
interface toolkit functions?
a) JDK
b) Java source
c) JVM
d) UML
8. The alphabet D in JDK stands for ?
a) Department
b) Development
c) Design
d) Desktop
Compiled by Nuzhat Memon
9. Java is a platform–independent at __________ level.
a) Source
b) Binary
c) Datatype
d) Both (a) and (b)
10. At binary level, platform–independent is possible due to which feature ?
a) Bytecode independent
b) Bytecode interpreter
c) Compiler
d) Source code
6
Compiled by Nuzhat Memon
7
11. In java, at which level platform- independence is possible due to bytecode
interpreter?
a) Binary
b) Machine
c) Source
d) Browser
12. Which of the following is right when Java file is created?
a) Name must start with Number ‘4' Only
b) Java source file & class name must be different.
c) Java source file & class name must be same.
d) Name must have symbol '$' at the end.
Compiled by Nuzhat Memon
13. Program’s capability of being moved easily from one computer system to
another is known as ______
a) Interpreter
b) Platform-independent
c) Compiler
d) Source code
14. Programs written in Java are compiled into _________ language.
a) Machine
b) Binary
c) Source code
d) Bytecode 8
Compiled by Nuzhat Memon
15. Java is an ................... Language.
a) Object Oriented Programming
b) Procedural Programming
c) Basic Programming
d) All of these
16. 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 9
Compiled by Nuzhat Memon
17. What is known as when program written in Java are compiled in to machine
language for a computer?
a) Java view modifier
b) Java virtual machine
c) Java visible modifier
d) Java visible machine
18. The machine language for the Java Virtual Machine is called ............... .
a) Java code
b) Type code
c) Java Bytecode
d) Code byte
10
Compiled by Nuzhat Memon
19. When we run the program, the Java interpreter calls which method?
a) class ( )
b) main( )
c) string( )
d) static( )
20. The _______routine can call other subroutines that are defined in the
same class or even in other classes.
a) class ( )
b) main ( )
c) string( )
d) static( ) 11
Compiled by Nuzhat Memon
21.Which words means that this routine can be called from outside the
program?
a) private
b) public
c) protected
d) packages
22. The rules that determines what is allowed are called the ________of the
language.
a) Syntax
b) Keyword
c) Literals
d) Variables 12
Compiled by Nuzhat Memon
13
23. 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
24. What is the disadvantage of native code?
a) Slow in execution speed
b) Does not remain machine independent
c) Virtual language
d) None of these
Compiled by Nuzhat Memon
25. Java source files are given the ______ name as the class they define.
a) same
b) different
c) double
d) Linear
26. What is the extension of Java source file?
a) .class
b) .java
c) .javac
d) .jvm
14
Compiled by Nuzhat Memon
27. What happen when program gets compiled without error?
a) Creates a class file
b) Show the output of program
c) Create a java file
d) Create a binary file
28. What is the extension of class file?
a) .class
b) .java
c) .javac
d) .jvm 15
Compiled by Nuzhat Memon
29. While creating Java what must be the same ?
a) folder name, file name
b) Class name , extension
c) Class name, file name
d) Class name ,folder name
30. 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 Bytecode (*.class)
b) Java class (*.exe)
c) Java typecode (*obj)
d) Java typecode (*.obj) 16
Compiled by Nuzhat Memon
17
31. Which extension is used to source file of java language, written in a text
editor?
a) .class
b) .html
c) .jpg
d) .java
32. By using which extension file java interpreter byte code executes?
a) .class
b) .txt
c) .html
d) .java
Compiled by Nuzhat Memon
18
33. Which of the following command is given in JDK using java interpreter?
a) run callcost
b) java callcost
c) javarc callcost
d) javaRun callcost
34. Which of the following way the 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
Compiled by Nuzhat Memon
19
35. How many basic (primitive) data types are supported in Java?
a) 8
b) 2
c) 16
d) 12
36. Which of the followings are primitive data types?
a) byte, short int, long
b) float, double
c) char, boolean
d) All of these
Compiled by Nuzhat Memon
37. Which of the following is not a basic data type in Java?
a) Char
b) Long
c) Byte
d) String
38. What is the default data type of floating point literal ? OR Which of the
following data type is used for real numbers ?
a) Double
b) Float
c) Int
d) Long 20
Compiled by Nuzhat Memon
39. Which character set is used for char data type in Java?
a) ASCII
b) EBCIDIC
c) Unicode
d) All of these
40. What is the default value of boolean type data?
a) True
b) False
c) 0
d) Null
21
Compiled by Nuzhat Memon
41. Which of the data type hold the integers?
a) byte, short
b) int
c) long
d) All of these
42. In Java, a name used for constant value is known as what?
a) ASCII
b) Unicode Quote
c) Literal
d) String return 22
Compiled by Nuzhat Memon
43. Which data types are machine-independent?
a) Primitive
b) Non Primitive
c) Static
d) Public
44. __________ numbers in Java are compliant with IEEE754.
a) Real
b) Integer
c) Character
d) String
23
Compiled by Nuzhat Memon
24
45. Which determines the required memory size, type of values, range of
values and type of operations that can be performed?
a) Data type
b) Literals
c) Values
d) Variable
46. From the following which is illegal name of variable in java?
a) Result
b) 4me
c) amount$
d) price$
Compiled by Nuzhat Memon
47. __________ can take different values at different times during the
execution of the program and always refer to the same memory location
a) Data type
b) Variable
c) Literal
d) All of these
48. Which of the following is the correct syntax to declare variable in Java?
a) (type-name) <variable — name>;
b) {type - name} <variable - names>;
c) [type — name ] {variable — name};
d) <type - name> {variable - names}; 25
Compiled by Nuzhat Memon
49. Which of the following is not allowed as first character in valid variable name?
a) Underscore(_)
b) Digit
c) Dollar($)
d) Letter
50. Which of the following is right way to define variable?
a) discount rate
b) $age
c) 4youpeople
d) %discount
26
Compiled by Nuzhat Memon
51. What is used for a constant value?
a) Literal
b) Variable
c) Class
d) Objects
52. Java 7 also supports binary numbers, using digits 0 and 1 but it should be
prefix by which of the following?
a) B
b) 0b or 0B
c) B1
d) b0 27
Compiled by Nuzhat Memon
53. A _________ is a sequence of characters.
a) Character
b) Boolean
c) String
d) Int
54. String literals is a sequence of characters enclosed in which quotes?
a) ()
b) “ “
c) ‘ ‘
d) {}
28
Compiled by Nuzhat Memon
55. In java, boolean and char data type takes how many bytes of storage space?
a) 8 bytes
b) 4 bytes
c) 2 bytes
d) 1 byte
56. What is the storage space for data type float and int in java ?
a) 8 bytes
b) 2 bytes
c) 4 bytes
d) 1 byte 29
Compiled by Nuzhat Memon
57. In java, for type boolean there are precisely two literals, which are they?
a) Y or N
b) 0 and 1
c) Yes or no
d) True or False
58. Which data type holds one of the two logical values true or false?
a) Char
b) Boolean
c) Long
d) Double
30
Compiled by Nuzhat Memon
59. ______ literals consists of u followed by 4 hexadecimal digits for ex. the
character literal 'u00E9' represents the Unicode character that is an "e".
a) Unicode
b) Character
c) String
d) Integer
60. To make a literal of______ type, we have to append an F or f as a suffix to
the number.
a) Float
b) Double
c) Long
d) Int
31
Compiled by Nuzhat Memon
61. In Java, variable name can begin with which of the following ?
a) Dollar sign
b) Alphabet
c) Underscore(_)
d) All of these
62. What is the range of octal number?
a) 0 to 8
b) 0 to 9 and A to F
c) 0 to 16
d) 0 to 14
32
Compiled by Nuzhat Memon
63. 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 16
d) 0 to 14
64. Which of the following is not a proper example of Hexa decimal number?
a) OXFF7A
b) OX39A2
c) OABC
d) OX532D 33
Compiled by Nuzhat Memon
65. Which type of literal not associated with any numeric value?
a) double
b) boolean
c) int
d) string
66. Which statement is ignored by the computer?
a) Literal
b) Expression
c) Comment
d) Variable
34
Compiled by Nuzhat Memon
67. Which of the following is a valid long literal?
a) ABH8097
b) L990023
c) 904423
d) 0xnf029L
68. Which of the following is a valid declaration of a char ?
a) char ch =‘utea’;
b) char ca=‘tea’;
c) char cr=‘u0223’;
d) char cc=‘itea’
35
Compiled by Nuzhat Memon
69. Which sign is used to insert single line comment in Java ?
a) /* and */
b) /** and */
c) //
d) #
70. In java, the text written in /*.....*/ is considered as what?
a) Method
b) Comment
c) Function
d) Variable
36
Compiled by Nuzhat Memon
71. Which type of comment used to creating API documentation from the
code in Java?
a) Documentation Comment
b) Multi-line
c) Single-Line
d) None
72. What sign is used for creating API documentation from the code?
a) /**....*/
b) //**....***//
c) 
d) // 37
Compiled by Nuzhat Memon
38
73. What will be the result of arithmetic expression 7/2 ?
a) 3
b) 3.5
c) 1
d) 0
74. What will be the result of arithmetic expression -7%2 ?
a) -3
b) -1
c) 1
d) -3.5
Compiled by Nuzhat Memon
39
75. With modulus operator %, if first operand is negative, the result is ______.
a) Negative
b) Positive
c) True
d) False
76. What will be the result of arithmetic expression -7.5%2?
a) -3
b) -1.5
c) 1.5
d) Error
Compiled by Nuzhat Memon
77. Within string, special characters can be represented using the _____.
a) Backslash ()
b) Forward slash(/)
c) Question mark (?)
d) Exclamation mark (!)
78. Which of the following escape code is used for backspace in java?
a) k
b) b
c) n
d) t
40
Compiled by Nuzhat Memon
79. Which of the following is not a basic arithmetic operator of java?
a) 
b) -
c) *
d) +
80. 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) 0
b) 22
c) 7
d) 3.5
41
Compiled by Nuzhat Memon
42
81. 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
Compiled by Nuzhat Memon
82. Which logical operator returns true only if its operands are different (one
true and one false) and false otherwise?
a) XOR
b) AND
c) OR
d) NOT
83. From the following which is not logical operator in Java ?
a) AND
b) OR
c) NOT
d) Equal to 43
Compiled by Nuzhat Memon
84. Using which operator, we will find opposite result?
a) XOR
b) NOT
c) OR
d) AND
85. Which operator is used to concatenate a string in java ?
a) =
b) &
c) *
d) +
44
Compiled by Nuzhat Memon
86. Which of the two symbols are used in the conditional operator in Java ?
a) ? and :
b) : and *
c) # and ?
d) / and ?
87. 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>
45
Compiled by Nuzhat Memon
88. Which operators are called increment and decrement operators?
a) ++ and – –
b) +/ and -/
c) + and –
d) – and –
89. What is known as post decrement in Java when operator is used after
variable name ?
a) <<
b) ++
c) --
d) >> 46
Compiled by Nuzhat Memon
90. What is the output of "x=4; y=3+--x;" code?
a) x=3, y=6
b) x=4, y=7
c) x=4,y=-1
d) x=4,y=1
91. Evaluate the following expression, if x=3, y=5 and z=10, ++z + y – y + z +
x++
a) 24
b) 23
c) 20
d) 25
47
Compiled by Nuzhat Memon
92. From the following which is not a comparison operator in java?
a) >
b) <
c) >=
d) +
93. Which sign is used for “A not equal to B ” in comparison operator in java ?
a) A=B
b) A!=B
c) A not equal to B
d) A==B 48
Compiled by Nuzhat Memon
94. What is the full form code of "q &&=p" shorthand assignment?
a) p=q && p
b) q=q && p
c) p=p & q
d) p==q
95. 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 49
Compiled by Nuzhat Memon
50
96. Which statement is a group of statements enclosed between a pair of
braces { } ?
a) block
b) Loops
c) If
d) Switch
97. 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 Memon
98. When a variable is declared inside a block, what is called __________
a) Global
b) Local
c) Label
d) Repetitive
99. Without the ____ , there would have been a "division by zero" error at
runtime.
a) Short-circuiting
b) Type cast
c) Expression
d) All of these 51
Compiled by Nuzhat Memon
100. How many types of control structures are there in Java?
a) Four
b) Two
c) Three
d) One
101. Control structures in java is divided into two types : loops and what?
a) Message
b) Function
c) Alerts
d) Branches 52
Compiled by Nuzhat Memon
53
102. 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
103. Which of the following is an example of If statement?
a) branching
b) decision
c) selective
d) All of these
Compiled by Nuzhat Memon
104. Which statement is executed if the value of Boolean expression is true?
if (boolean expression)
{
<statement1>
}
else
{
<statement2>
}
a) Statement2
b) Statement1
c) Error message
d) Statement 3 54
Compiled by Nuzhat Memon
55
105. In statement (x==0) || (y==0) if one is true, then what is the result ?
a) True
b) False
c) Error
d) None of these
106. In statement A && B, if both A and B are true, then what is the result ?
a) True
b) False
c) Error
d) None of these
Compiled by Nuzhat Memon
107. 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) Nested if
b) Switch
c) Control
d) Repeat
108. In ______ case , if a match is found, the respective case statement are
executed.
a) Switch
b) If
c) For
d) While 56
Compiled by Nuzhat Memon
109. In switch case, if no match is found then which statement is executed?
a) Nested if
b) default
c) Control
d) Repeat
110. In Which loop, test expression is evaluated first and the statements in the loop
are executed if condition is true.
a) for and do while
b) for and while
c) switch case
d) if condition
57
Compiled by Nuzhat Memon
111. Which loops are called entry-controlled or pre-test loop constructs?
a) for & while
b) while & do ... while
c) If
d) Switch case
112. Which loop is exit-controlled or post-test loop constructs?
a) do .... while
b) while
c) for
d) if
58
Compiled by Nuzhat Memon
113. What do we call the statement that enable to control the flow of execution?
a) Loops
b) Control Structures
c) Inheritance
d) Aggregation
114. 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
59
Compiled by Nuzhat Memon
115. In a loop, _________statement is used to exit the loop.
a) break
b) continue
c) case
d) For
116. The ________ statement is used to transfer the control outside
switch or loop structure.
a) Break
b) Continue
c) Case
d) For
60
Compiled by Nuzhat Memon
117. In java, which statement is used to skip the following statements in a loop
and continue with next iteration?
a) Continue
b) Go
c) Break
d) Run
118. Use of ______statement is used to skip the following statements in a loop
and continue with the next iteration. OR In java, which statement is used to
exit from loop structure?
a) break
b) continue
c) case
d) for
61
Compiled by Nuzhat Memon
119. User can create Java source file by using ________ application
a) Scite editor
b) ASCII text editor
c) Both (a) and (b)
d) None of these
120. Which of the following editor is used to create Java file in Ubuntu?
a) Scite
b) Calc
c) Writer
d) Wordpad
62
Compiled by Nuzhat Memon
121. In Java, the program is compiled without any error, which command is
used to execute it?
a) Tools  Go
b) Tools  build
c) Tools  run
d) Tools  compile
122. From the following which methods are used to display results?
a) system.out.print()
b) system.out.display()
c) System.out.println()
d) Both (a) and (c) 63
Compiled by Nuzhat Memon
123. Match the following :
a) (1-c, 2-d, 3-a, 4-b)
b) (1-c, 2-d, 3-b, 4-a)
c) (1-a, 2-b, 3-d, 4-c)
d) (1-b, 2-c, 3-d, 4-a)
64
A B
1 byte, boolean a 8 bytes
2 short, char b 1 byte
3 int, float c 2 bytes
4 long, double d 4 bytes
Compiled by Nuzhat Memon
124. Match the following :
a) (1-d, 2-a, 3-c, 4-b)
b) (1-d, 2-a, 3-b, 4-c)
c) (1-a, 2-b, 3-c, 4-d)
d) (1-b, 2-a, 3-d, 4-c)
65
A B
1 n a Tab
2 t b New line
3 b c Carriage return
4 r d Backspace
Compiled by Nuzhat Memon
125. Find out the correct literal type from the list.
a) (1-f, 2-g, 3-e, 4-c, 5-a, 6-b, 7-d)
b) (1-c, 2-g, 3-f, 4-e, 5-b, 6-a, 7-d) 66
A B
1 4L a Floating point literal
2 -56 b String literal
3 0xFF7A c Unicode literal
4 u00E9 d Scientific notation
5 1.2F e Hexadecimal literal
6 “Many, “Congratulations!”” f Long integer literal
7 1.24E-107 g Negative integer
Compiled by Nuzhat Memon
126. Which class defines a whole set of mathematical operations?
a) Math
b) Mathematical
c) ams math
d) mathc
67
Compiled by Nuzhat Memon
Thanks for watching 

Std 12 chapter 7 Java Basics Important MCQs

  • 1.
    Compiled by NuzhatMemon CHAPTER 7 JAVA BASICS Important MCQs
  • 2.
    Compiled by NuzhatMemon Important MCQs : 1. 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 2. Java was developed by which company in 1991? a) Sun Microsystems b) ABM c) Microsoft d) Apple 2
  • 3.
    Compiled by NuzhatMemon 3. Which of the Java syntax is very similar to which language? a) C b) Fortan c) SQL d) FoxPro 4. 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) 3
  • 4.
    Compiled by NuzhatMemon 4 5. In java, who provides basic data types, system I/O capabilities and other utility functions? a) JDK b) JVM c) Class libraries d) UML 6. Basic classes are part of the __________ a) JDK b) JVM c) UML d) OML
  • 5.
    Compiled by NuzhatMemon 5 7. Who have classes to support networking, common Internet protocols and interface toolkit functions? a) JDK b) Java source c) JVM d) UML 8. The alphabet D in JDK stands for ? a) Department b) Development c) Design d) Desktop
  • 6.
    Compiled by NuzhatMemon 9. Java is a platform–independent at __________ level. a) Source b) Binary c) Datatype d) Both (a) and (b) 10. At binary level, platform–independent is possible due to which feature ? a) Bytecode independent b) Bytecode interpreter c) Compiler d) Source code 6
  • 7.
    Compiled by NuzhatMemon 7 11. In java, at which level platform- independence is possible due to bytecode interpreter? a) Binary b) Machine c) Source d) Browser 12. Which of the following is right when Java file is created? a) Name must start with Number ‘4' Only b) Java source file & class name must be different. c) Java source file & class name must be same. d) Name must have symbol '$' at the end.
  • 8.
    Compiled by NuzhatMemon 13. Program’s capability of being moved easily from one computer system to another is known as ______ a) Interpreter b) Platform-independent c) Compiler d) Source code 14. Programs written in Java are compiled into _________ language. a) Machine b) Binary c) Source code d) Bytecode 8
  • 9.
    Compiled by NuzhatMemon 15. Java is an ................... Language. a) Object Oriented Programming b) Procedural Programming c) Basic Programming d) All of these 16. 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 9
  • 10.
    Compiled by NuzhatMemon 17. What is known as when program written in Java are compiled in to machine language for a computer? a) Java view modifier b) Java virtual machine c) Java visible modifier d) Java visible machine 18. The machine language for the Java Virtual Machine is called ............... . a) Java code b) Type code c) Java Bytecode d) Code byte 10
  • 11.
    Compiled by NuzhatMemon 19. When we run the program, the Java interpreter calls which method? a) class ( ) b) main( ) c) string( ) d) static( ) 20. The _______routine can call other subroutines that are defined in the same class or even in other classes. a) class ( ) b) main ( ) c) string( ) d) static( ) 11
  • 12.
    Compiled by NuzhatMemon 21.Which words means that this routine can be called from outside the program? a) private b) public c) protected d) packages 22. The rules that determines what is allowed are called the ________of the language. a) Syntax b) Keyword c) Literals d) Variables 12
  • 13.
    Compiled by NuzhatMemon 13 23. 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 24. What is the disadvantage of native code? a) Slow in execution speed b) Does not remain machine independent c) Virtual language d) None of these
  • 14.
    Compiled by NuzhatMemon 25. Java source files are given the ______ name as the class they define. a) same b) different c) double d) Linear 26. What is the extension of Java source file? a) .class b) .java c) .javac d) .jvm 14
  • 15.
    Compiled by NuzhatMemon 27. What happen when program gets compiled without error? a) Creates a class file b) Show the output of program c) Create a java file d) Create a binary file 28. What is the extension of class file? a) .class b) .java c) .javac d) .jvm 15
  • 16.
    Compiled by NuzhatMemon 29. While creating Java what must be the same ? a) folder name, file name b) Class name , extension c) Class name, file name d) Class name ,folder name 30. 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 Bytecode (*.class) b) Java class (*.exe) c) Java typecode (*obj) d) Java typecode (*.obj) 16
  • 17.
    Compiled by NuzhatMemon 17 31. Which extension is used to source file of java language, written in a text editor? a) .class b) .html c) .jpg d) .java 32. By using which extension file java interpreter byte code executes? a) .class b) .txt c) .html d) .java
  • 18.
    Compiled by NuzhatMemon 18 33. Which of the following command is given in JDK using java interpreter? a) run callcost b) java callcost c) javarc callcost d) javaRun callcost 34. Which of the following way the 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
  • 19.
    Compiled by NuzhatMemon 19 35. How many basic (primitive) data types are supported in Java? a) 8 b) 2 c) 16 d) 12 36. Which of the followings are primitive data types? a) byte, short int, long b) float, double c) char, boolean d) All of these
  • 20.
    Compiled by NuzhatMemon 37. Which of the following is not a basic data type in Java? a) Char b) Long c) Byte d) String 38. What is the default data type of floating point literal ? OR Which of the following data type is used for real numbers ? a) Double b) Float c) Int d) Long 20
  • 21.
    Compiled by NuzhatMemon 39. Which character set is used for char data type in Java? a) ASCII b) EBCIDIC c) Unicode d) All of these 40. What is the default value of boolean type data? a) True b) False c) 0 d) Null 21
  • 22.
    Compiled by NuzhatMemon 41. Which of the data type hold the integers? a) byte, short b) int c) long d) All of these 42. In Java, a name used for constant value is known as what? a) ASCII b) Unicode Quote c) Literal d) String return 22
  • 23.
    Compiled by NuzhatMemon 43. Which data types are machine-independent? a) Primitive b) Non Primitive c) Static d) Public 44. __________ numbers in Java are compliant with IEEE754. a) Real b) Integer c) Character d) String 23
  • 24.
    Compiled by NuzhatMemon 24 45. Which determines the required memory size, type of values, range of values and type of operations that can be performed? a) Data type b) Literals c) Values d) Variable 46. From the following which is illegal name of variable in java? a) Result b) 4me c) amount$ d) price$
  • 25.
    Compiled by NuzhatMemon 47. __________ can take different values at different times during the execution of the program and always refer to the same memory location a) Data type b) Variable c) Literal d) All of these 48. Which of the following is the correct syntax to declare variable in Java? a) (type-name) <variable — name>; b) {type - name} <variable - names>; c) [type — name ] {variable — name}; d) <type - name> {variable - names}; 25
  • 26.
    Compiled by NuzhatMemon 49. Which of the following is not allowed as first character in valid variable name? a) Underscore(_) b) Digit c) Dollar($) d) Letter 50. Which of the following is right way to define variable? a) discount rate b) $age c) 4youpeople d) %discount 26
  • 27.
    Compiled by NuzhatMemon 51. What is used for a constant value? a) Literal b) Variable c) Class d) Objects 52. Java 7 also supports binary numbers, using digits 0 and 1 but it should be prefix by which of the following? a) B b) 0b or 0B c) B1 d) b0 27
  • 28.
    Compiled by NuzhatMemon 53. A _________ is a sequence of characters. a) Character b) Boolean c) String d) Int 54. String literals is a sequence of characters enclosed in which quotes? a) () b) “ “ c) ‘ ‘ d) {} 28
  • 29.
    Compiled by NuzhatMemon 55. In java, boolean and char data type takes how many bytes of storage space? a) 8 bytes b) 4 bytes c) 2 bytes d) 1 byte 56. What is the storage space for data type float and int in java ? a) 8 bytes b) 2 bytes c) 4 bytes d) 1 byte 29
  • 30.
    Compiled by NuzhatMemon 57. In java, for type boolean there are precisely two literals, which are they? a) Y or N b) 0 and 1 c) Yes or no d) True or False 58. Which data type holds one of the two logical values true or false? a) Char b) Boolean c) Long d) Double 30
  • 31.
    Compiled by NuzhatMemon 59. ______ literals consists of u followed by 4 hexadecimal digits for ex. the character literal 'u00E9' represents the Unicode character that is an "e". a) Unicode b) Character c) String d) Integer 60. To make a literal of______ type, we have to append an F or f as a suffix to the number. a) Float b) Double c) Long d) Int 31
  • 32.
    Compiled by NuzhatMemon 61. In Java, variable name can begin with which of the following ? a) Dollar sign b) Alphabet c) Underscore(_) d) All of these 62. What is the range of octal number? a) 0 to 8 b) 0 to 9 and A to F c) 0 to 16 d) 0 to 14 32
  • 33.
    Compiled by NuzhatMemon 63. 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 16 d) 0 to 14 64. Which of the following is not a proper example of Hexa decimal number? a) OXFF7A b) OX39A2 c) OABC d) OX532D 33
  • 34.
    Compiled by NuzhatMemon 65. Which type of literal not associated with any numeric value? a) double b) boolean c) int d) string 66. Which statement is ignored by the computer? a) Literal b) Expression c) Comment d) Variable 34
  • 35.
    Compiled by NuzhatMemon 67. Which of the following is a valid long literal? a) ABH8097 b) L990023 c) 904423 d) 0xnf029L 68. Which of the following is a valid declaration of a char ? a) char ch =‘utea’; b) char ca=‘tea’; c) char cr=‘u0223’; d) char cc=‘itea’ 35
  • 36.
    Compiled by NuzhatMemon 69. Which sign is used to insert single line comment in Java ? a) /* and */ b) /** and */ c) // d) # 70. In java, the text written in /*.....*/ is considered as what? a) Method b) Comment c) Function d) Variable 36
  • 37.
    Compiled by NuzhatMemon 71. Which type of comment used to creating API documentation from the code in Java? a) Documentation Comment b) Multi-line c) Single-Line d) None 72. What sign is used for creating API documentation from the code? a) /**....*/ b) //**....***// c) d) // 37
  • 38.
    Compiled by NuzhatMemon 38 73. What will be the result of arithmetic expression 7/2 ? a) 3 b) 3.5 c) 1 d) 0 74. What will be the result of arithmetic expression -7%2 ? a) -3 b) -1 c) 1 d) -3.5
  • 39.
    Compiled by NuzhatMemon 39 75. With modulus operator %, if first operand is negative, the result is ______. a) Negative b) Positive c) True d) False 76. What will be the result of arithmetic expression -7.5%2? a) -3 b) -1.5 c) 1.5 d) Error
  • 40.
    Compiled by NuzhatMemon 77. Within string, special characters can be represented using the _____. a) Backslash () b) Forward slash(/) c) Question mark (?) d) Exclamation mark (!) 78. Which of the following escape code is used for backspace in java? a) k b) b c) n d) t 40
  • 41.
    Compiled by NuzhatMemon 79. Which of the following is not a basic arithmetic operator of java? a) b) - c) * d) + 80. 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) 0 b) 22 c) 7 d) 3.5 41
  • 42.
    Compiled by NuzhatMemon 42 81. 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
  • 43.
    Compiled by NuzhatMemon 82. Which logical operator returns true only if its operands are different (one true and one false) and false otherwise? a) XOR b) AND c) OR d) NOT 83. From the following which is not logical operator in Java ? a) AND b) OR c) NOT d) Equal to 43
  • 44.
    Compiled by NuzhatMemon 84. Using which operator, we will find opposite result? a) XOR b) NOT c) OR d) AND 85. Which operator is used to concatenate a string in java ? a) = b) & c) * d) + 44
  • 45.
    Compiled by NuzhatMemon 86. Which of the two symbols are used in the conditional operator in Java ? a) ? and : b) : and * c) # and ? d) / and ? 87. 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> 45
  • 46.
    Compiled by NuzhatMemon 88. Which operators are called increment and decrement operators? a) ++ and – – b) +/ and -/ c) + and – d) – and – 89. What is known as post decrement in Java when operator is used after variable name ? a) << b) ++ c) -- d) >> 46
  • 47.
    Compiled by NuzhatMemon 90. What is the output of "x=4; y=3+--x;" code? a) x=3, y=6 b) x=4, y=7 c) x=4,y=-1 d) x=4,y=1 91. Evaluate the following expression, if x=3, y=5 and z=10, ++z + y – y + z + x++ a) 24 b) 23 c) 20 d) 25 47
  • 48.
    Compiled by NuzhatMemon 92. From the following which is not a comparison operator in java? a) > b) < c) >= d) + 93. Which sign is used for “A not equal to B ” in comparison operator in java ? a) A=B b) A!=B c) A not equal to B d) A==B 48
  • 49.
    Compiled by NuzhatMemon 94. What is the full form code of "q &&=p" shorthand assignment? a) p=q && p b) q=q && p c) p=p & q d) p==q 95. 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 49
  • 50.
    Compiled by NuzhatMemon 50 96. Which statement is a group of statements enclosed between a pair of braces { } ? a) block b) Loops c) If d) Switch 97. 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) []
  • 51.
    Compiled by NuzhatMemon 98. When a variable is declared inside a block, what is called __________ a) Global b) Local c) Label d) Repetitive 99. Without the ____ , there would have been a "division by zero" error at runtime. a) Short-circuiting b) Type cast c) Expression d) All of these 51
  • 52.
    Compiled by NuzhatMemon 100. How many types of control structures are there in Java? a) Four b) Two c) Three d) One 101. Control structures in java is divided into two types : loops and what? a) Message b) Function c) Alerts d) Branches 52
  • 53.
    Compiled by NuzhatMemon 53 102. 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 103. Which of the following is an example of If statement? a) branching b) decision c) selective d) All of these
  • 54.
    Compiled by NuzhatMemon 104. Which statement is executed if the value of Boolean expression is true? if (boolean expression) { <statement1> } else { <statement2> } a) Statement2 b) Statement1 c) Error message d) Statement 3 54
  • 55.
    Compiled by NuzhatMemon 55 105. In statement (x==0) || (y==0) if one is true, then what is the result ? a) True b) False c) Error d) None of these 106. In statement A && B, if both A and B are true, then what is the result ? a) True b) False c) Error d) None of these
  • 56.
    Compiled by NuzhatMemon 107. 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) Nested if b) Switch c) Control d) Repeat 108. In ______ case , if a match is found, the respective case statement are executed. a) Switch b) If c) For d) While 56
  • 57.
    Compiled by NuzhatMemon 109. In switch case, if no match is found then which statement is executed? a) Nested if b) default c) Control d) Repeat 110. In Which loop, test expression is evaluated first and the statements in the loop are executed if condition is true. a) for and do while b) for and while c) switch case d) if condition 57
  • 58.
    Compiled by NuzhatMemon 111. Which loops are called entry-controlled or pre-test loop constructs? a) for & while b) while & do ... while c) If d) Switch case 112. Which loop is exit-controlled or post-test loop constructs? a) do .... while b) while c) for d) if 58
  • 59.
    Compiled by NuzhatMemon 113. What do we call the statement that enable to control the flow of execution? a) Loops b) Control Structures c) Inheritance d) Aggregation 114. 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 59
  • 60.
    Compiled by NuzhatMemon 115. In a loop, _________statement is used to exit the loop. a) break b) continue c) case d) For 116. The ________ statement is used to transfer the control outside switch or loop structure. a) Break b) Continue c) Case d) For 60
  • 61.
    Compiled by NuzhatMemon 117. In java, which statement is used to skip the following statements in a loop and continue with next iteration? a) Continue b) Go c) Break d) Run 118. Use of ______statement is used to skip the following statements in a loop and continue with the next iteration. OR In java, which statement is used to exit from loop structure? a) break b) continue c) case d) for 61
  • 62.
    Compiled by NuzhatMemon 119. User can create Java source file by using ________ application a) Scite editor b) ASCII text editor c) Both (a) and (b) d) None of these 120. Which of the following editor is used to create Java file in Ubuntu? a) Scite b) Calc c) Writer d) Wordpad 62
  • 63.
    Compiled by NuzhatMemon 121. In Java, the program is compiled without any error, which command is used to execute it? a) Tools  Go b) Tools  build c) Tools  run d) Tools  compile 122. From the following which methods are used to display results? a) system.out.print() b) system.out.display() c) System.out.println() d) Both (a) and (c) 63
  • 64.
    Compiled by NuzhatMemon 123. Match the following : a) (1-c, 2-d, 3-a, 4-b) b) (1-c, 2-d, 3-b, 4-a) c) (1-a, 2-b, 3-d, 4-c) d) (1-b, 2-c, 3-d, 4-a) 64 A B 1 byte, boolean a 8 bytes 2 short, char b 1 byte 3 int, float c 2 bytes 4 long, double d 4 bytes
  • 65.
    Compiled by NuzhatMemon 124. Match the following : a) (1-d, 2-a, 3-c, 4-b) b) (1-d, 2-a, 3-b, 4-c) c) (1-a, 2-b, 3-c, 4-d) d) (1-b, 2-a, 3-d, 4-c) 65 A B 1 n a Tab 2 t b New line 3 b c Carriage return 4 r d Backspace
  • 66.
    Compiled by NuzhatMemon 125. Find out the correct literal type from the list. a) (1-f, 2-g, 3-e, 4-c, 5-a, 6-b, 7-d) b) (1-c, 2-g, 3-f, 4-e, 5-b, 6-a, 7-d) 66 A B 1 4L a Floating point literal 2 -56 b String literal 3 0xFF7A c Unicode literal 4 u00E9 d Scientific notation 5 1.2F e Hexadecimal literal 6 “Many, “Congratulations!”” f Long integer literal 7 1.24E-107 g Negative integer
  • 67.
    Compiled by NuzhatMemon 126. Which class defines a whole set of mathematical operations? a) Math b) Mathematical c) ams math d) mathc 67
  • 68.
    Compiled by NuzhatMemon Thanks for watching 