Std12e ch7
Std12e ch7
Java Basics
-------------------------------------------------------------------------------------------------------
1. Java is an …………………language.
a) Object Oriented Programming b) Procedural programming
c) Basic programming d) All
3. In Java, who provides basic data types, system I/O capabilities and other utility
functions?
a) JDK b) class libraries c) JVM d) UML
5. Who have classes to support networking, common Internet protocols and interface
toolkit functions?
a) JDK b) Java Source c) JVM d) UML
7. 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
11. What do we called the machine language which is used for JVM?
a) JavaScript b) Java bytecode c) Java Binary code d) Source code
1
15. Java source files are given the………… name as the class they define.
a) same b) different c) double d) linear
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( )
21. Write down the right process of compiling and executing a Java application.
Ans. Java Source File - Java Compiler - Java Bytecode File – JVM
22. Which words means that this routine can be called from outside the program?
a) private b) public c) protected d) packages
23. The rules that determines what is allowed are called the …………of the language.
a)Syntax b) Keyword c) Literals d) Variables
25. Function header and the sequence of statements enclosed between which braces?
a) { } b) < > c) [ ] d) ( )
30. Which determines the required memory size, type of values, range of values and
type of operations that can be performed.
a) Data type b) Variable c) Literals d) Keyword
34. Name the data type which hold the real numbers.
a) float b) double c) Int d) Both a and b
35. Which data type hold a single character from Unicode character set?
a) char b) Boolean c) Long d) Double
36. Which data type holds one of the two logical values true or false?
a) char b) Boolean c) Long d) Double
3
a) (1-c, 2-d, 3-a, 4-b) b) (1-c, 2-d, 3-b, 4-a)
c) (1-d, 2-c, 3-a, 4-b) d) (1-c, 2-d, 3-b, 4-a)
43. Which can take different data values at different times during the executing of the
program?
a) Variable b) Data type c) Literals d) Values
44. Which of the following is the correct syntax to declare variable in Java.
a) <type - name> {variable - names}; b) {type - name} <variable - names>;
c) [type – name ] {variable – name}; c) (type-name) <variable – name>;
50. What do we call the words who have special use in Java and cannot be used by
the programmer for the other purposes?
a) Expression b) Reserved Word c) Variable d) Boolean
53. Which type of literal are used to represent integer or real numbers?
a) Boolean b) Numeric c) String d) character
4
55. What is the range of Octal numbers?
a) 0 to F (0-9 and A-F) base 16 b) 0 to 7 (base 8) c) 1 to 8 d) 1 to 8 (base
10)
60. Which type of literals are not associated with any numeric value?
a) double b) Boolean c) int d) double
62. Which type of literals are expressed by a single character surrounded by single
quotes?
a) character b) Boolean c) String d) int
65. Within string, special characters can be represented using the ……………….
a) backslash(\) b) forward slash(/) c) * d) $
5
67. Find out the correct literal type from the list.
(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, f Long Integer literal
\"Congratulations!\""
7 1.24E-107 g Negative integer
(a) (1-f, 2-g, 3-e, 4-c, 5-a, 6-b, 7-d) (b) (1-f, 2-g, 3-c, 4-e, 5-b, 6-d, 7-a)
69. Which type of comment is begin with double slashes (//) and extends till the end
of a line?
a) Single-line b) Multi-line c) document d) None of above
71. Which type of comment used to creating API documentation form the code in
Java?
a) Documentation Comment b) Multi-line c) Single-Line d) None
75. Which type of operators can be applied on any type of numeric data?
a) Arithmetic b) Assignment c) Logical d) Conditional
6
78. What do we call the conversion where lower range data type is implicitly
converted to higher data type?
a) Type cast b) Promotion c) Literals d) Variable
80. With modulus operator %, if first operand is negative, the result is …………
a) negative b) positive c) True d) False
84. After applying comparison operator, the result of expression is come in which
data type?
a) Integer b) Boolean c) Integer d) Float
87. In statement "A && B" if both A and B both are true then what is the result?
a) True b) False c) True d) False
88. In statement "(x==0) || (y==0)" if one is true then what is the result?
a) True b) False c) True d) False
90. 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
7
91. Which operator is used as assignment operator?
a) = b) = = c) >= d) <=
93. What is the output of "(N%2 ==0) ? (N/2) : (3*N+1)" code where N=8?
a) 25 b) 4 c) 26 d) 2
95. 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
96. Which facilities of Java we may use when we want to force a conversion that
wouldn't be done automatically?
a) Type cast b) Promotion c) Literals d) Data type
97. What do we call the statement that enable to control the flow of execution?
a) Loops b) Control Structures c) Inheritance d) Aggrigation
98. Which statement is a group of statements enclosed between a pair of braces {}?
a) block b) Loops c) If d) Switch
99. Which 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) While d) For
100. In ………..case , if a match is found, the respective case statement are executed.
a) switch b) If c) For d) While
103. In which loops, test expression is evaluated first and the statements in the loop
are executed if condition is true.
a) for & do ... while b) for & while c) If d) Switch case
104. Which loops are called entry - controlled or pre - test loop constructs?
a) for & while b) while & do ... while c) If d) Switch case
8
106. The……………statement is used to transfer the control outside switch or loop
structure.
a) break b) Continue c) case d) For
109. If we want to control which loop to break and which loop to reiterate, we can use
…………..
a) Labeled loops b) Labeled break c) break d) Continue
110. To use a labeled loop, add the label followed by ………….before the loop.
a) colon (:) b) semi colon(;) c) comma (,) d) dash ( - )
111. Use of ………….statement is used to skip the following statements in a loop and
continue with the next iteration.
a) break b) Continue c) case d) For
113. In Java, how many levels of visibility modifiers are available for access control?
a) 2 b) 4 c) 8 d) 6
114. Which of the following editor is used to create Java file in Ubuntu?
a) Scite b) Calc c) Writer d) Wordpad
117. Which of the following command is given in JDK using Java interpreter?
a) java CallCost b) run CallCost c) javarc CallCost d) javac CallCost
118. Which of the following is missing from compilation process to execute Java application?
Java source file (.java) Java Compiler (javac) JVM – Java Interpreter (java)
9
Textbook Exercise
1. How many basic (primitive) data types are supported in Java?
a) 2 b) 4 c) 16 d) 8
4. Which of the following is not allowed as first character in valid variable name?
a) Digit b) Underscore c) Letter d) Dollar
10