0% found this document useful (0 votes)
35 views

Std12e ch7

Uploaded by

barjesh924
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Std12e ch7

Uploaded by

barjesh924
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Chapter -7

Java Basics
-------------------------------------------------------------------------------------------------------

1. Java is an …………………language.
a) Object Oriented Programming b) Procedural programming
c) Basic programming d) All

2. Java was developed by which company in 1991?


a) Sun Microsystems b) Microsoft c) Apple d) ABM

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

4. Basic classes are part of the…………


a) JDK b) JVM c) UML d) OML

5. Who have classes to support networking, common Internet protocols and interface
toolkit functions?
a) JDK b) Java Source c) JVM d) UML

6. Java is platform - independent at ……………….. level.


a) Source b) binary c) Datatype d) Both a and b

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

8. At binary level, platform - independent is possible due to which feature?


a) Bytecode Independent b) Bytecode Interpreter c) Compiler d) Source code

9. Programs written in Java are compiled into ………………language.


a) machine b) Binary c) Source d) Bytecode

10. In Java virtual computer is known as………….


a) JVM b) JDK c) UML d) OML

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

12. What is the only disadvantage of using bytecode?


a) Slow in execution speed b) Machine independent
c) virtual language d) None

13. What is the disadvantage of native code?


a) Slow in execution speed b) Machine independent
c) Virtual language d) None

14. From the following what is not available in Java?


a) type casting b) typedef c) typecode d) Type

1
15. Java source files are given the………… name as the class they define.
a) same b) different c) double d) linear

16. What is the extension of Java source file?


a) .class b) .java c) .javac d) .jvm

17. What happen when program gets compiled without error?


a) Creates a class file b) Show the output of program
c) create java file d) create binary file

18. What is the extension of class file?


a) .class b) .java c) .javac d) .jvm

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

24. Text in angle bracket is used as a ………….that describes something actual we


need to type while writing actual program.
a) Place holder b) keyword c) literals d) variables

25. Function header and the sequence of statements enclosed between which braces?
a) { } b) < > c) [ ] d) ( )

26. Which can't exists by itself?


a) function b) method c) Main( ) d) variable

27. Method has to be a part of which section of Java?


a) class b) Literals c) Method d) main( )

28. Structure of Java program.

public class <class - name>


{
<optional - variable - declarations - and - methods>
public static void main (String [ ] args)
{
2
<statements>
}
<optional - variable - declarations - and - methods>
}

29. One compulsory class has which public method?


a) static b) main c) Syntax d) Literals

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

31. How many primitive data types are there in Java?


a) 3 b) 4 c) 8 d) 6

32. Name the primitive data types.


a) byte, short int, long b) float, double c) char, boolean. d) All of these

33. Name the data type which hold the integers.


a) byte, short b) int c) long d) All of these

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

37. Which data types are machine - independent?


a) Primitive b) Non Primitive c) Static d) Public

38. ……………numbers in Java are compliant with IEEE754.


a) Real b) Integer c) Character d) String

39. What is the meaning of IEEE754?


Ans. An international standard for defining floating - point numbers and
arithmetic.

40. What can store data in memory?


a) Data type b) Variable c) Keywords d) Operators

41. Match the followings.


(A) (B)
1 byte a 8 bytes
2 short b 4 bytes
3 int c 1 byte
4 double d 2 bytes

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)

42. Which of the following refers to the same memory location?


a) Variable b) Data type c) Literals d) Values

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>;

45. What is denoted by <> in "<type - name> {variable - names};" syntax?


a) item to be specified by user b) List of items c) Value d) Message

46. What is denoted by { } in "<type - name> {variable - names};" syntax?


a) item to be specified by user b) List of items c) Value d) Message

47. What is denoted by {variable-names} in "<type - name> {variable - names};"


syntax?
a) list of variables b) data type of variables c) value d) Message

48. What is denoted by <type-name> in "<type - name> {variable - names};" syntax?


a) list of variables b) data type of variables c) value d) Message

49. By which a variable name must be begin with?


a) Alphabet b) underscore c) dollar sign ($) d) All of these

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

51. Which of the following is the valid variable name in Java.


1) birth_date 2) CallCost 3) 4me 4) a1mp3
5) $price 6) %date$ 6) 34Call 7) date of_joining 8) Name#

a) 1,2,3,5,7,8 b) 1,2,4,5,8 c) 1,2,4,6,7 d) 1,3,4,5,6

52. What is used for a constant value?


a) Literal b) Variable c) Class d) Objects

53. Which type of literal are used to represent integer or real numbers?
a) Boolean b) Numeric c) String d) character

54. We can force a smaller number to be a long by appending which letter?


a) L or l b) B or b c) A or a d) O or o

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)

56. What is the range of Hexadecimal number?


a) 0 to F (0-9 and A-F) base 16 b) 0 to 7 (base 8) c) 1 to 16 d) 1 to 15

57. ……………….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

58. What is the default type of floating point literals?


a) double b) float c) int d) Long

59. 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

60. Which type of literals are not associated with any numeric value?
a) double b) Boolean c) int d) double

61. Boolean type literals has how many literals?


a) True b) False c) Yes d) both a and b

62. Which type of literals are expressed by a single character surrounded by single
quotes?
a) character b) Boolean c) String d) int

63. A …………is a sequence of characters.


a) character b) Boolean c) String d) int

64. Which type of literals is a sequence of characters enclosed in double quotes?


a) character b) string c) Boolean d) int

65. Within string, special characters can be represented using the ……………….
a) backslash(\) b) forward slash(/) c) * d) $

66. Match the followings.


(A) (B)
1 \n a Tab
2 \t b Backspace
3 \b c Carriage return
4 \r d New line

a) (1-d, 2-a, 3-c, 4-b) b) (1-d, 2-a, 3-b, 4-c)


c) (1-a, 2-d, 3-c, 4-b) d) (1-a, 2-d, 3-b, 4-c)

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)

68. Which statement is ignored by the computer?


a) Expression b) Comment c) Literals d) Variables

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

70. What do we use to apply multi-line comment?


a) /* ...... /* b) /* ....... */ c) */……*/ d) //…..*/

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

72. What do we use to apply documentation comment in Java?


a) /* ...... */ b) /** ........ */ c) //*…..*// d) //

73. The basic building blocks of expressions are………………..


a) literals b) variables c) function d) All of these

74. …………. are special symbols used to build an expression.


a) Operators b) Variables c) Literals d) Function

75. Which type of operators can be applied on any type of numeric data?
a) Arithmetic b) Assignment c) Logical d) Conditional

76. In which data type the result of "9*2" is stored?


a) Float b) Integer c) Long d) Double

77. In which data type the result of "9f/2f" is stored?


a) Float b) Integer c) Long d) Double

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

79. Which operator can also be used to concatenate a string?


a) + b) * c) - d) #

80. With modulus operator %, if first operand is negative, the result is …………
a) negative b) positive c) True d) False

81. Which operators are called increment and decrement operators?


a) ++ and -- b) +/ and -/ c) +, - d) +,-,-

82. What is the output of "x=4; y=3+x++;" code?


a) x=3, y=6 b) x=4, y=7 c) x=7,y=4 d) x=4,y=4

83. 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

84. After applying comparison operator, the result of expression is come in which
data type?
a) Integer b) Boolean c) Integer d) Float

85. In which part of programming relational operators are used?


a) If statements & loops b) Body part c) head part d) End part

86. List of logical operations.

No. Logical Operations Operators


1 AND &&
2 OR ||
3 XOR ^
4 NOT !

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

89. Using which operator, we will find opposite result?


a) XOR b) NOT c) OR d) AND

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) <=

92. Which operator is used as conditional operator?


a) ? and : b) % and ? c) : and ? d) ? and ?

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

94. What is the shorthand assignment of "a=a+b" code?


a) a+=b b) a=+b c) a++=b d) a==b

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

101. In switch case , if no match is found, when which statement is executed?


a) default b) loop c) control d) While

102. Java support 3 types of looping constructs:


a) for b) while c) do.... while d) All of these

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

105. ……………..loop is exit - controlled or post - test loop constructs.


a) do .... while b) While c) For d) If

8
106. The……………statement is used to transfer the control outside switch or loop
structure.
a) break b) Continue c) case d) For

107. In a loop, …………statement is used to exit the loop.


a) break b) Continue c) case d) For

108. Which class defines a whole set of mathematical operations?


a) Math b) Mathematical c) ams math d) mathc

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

112. Which of the following is an example of If statement?


a) Branching b) decision c) selective d) All of these

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

115. Which of the following is right when Java file is created?


a) Name must start with Number „2‟ 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.

116. Which of the following is comment statement in Java?


a) /* ….*/ b) /#....#/ c) \*….*\ d) /*…../*

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)

a) Java Bookcode file (*.cla) b) Java Bitecode file(*.csc)


c) JavaBytecode file (*.class) d) Java Compilercode (*.Javacr)

9
Textbook Exercise
1. How many basic (primitive) data types are supported in Java?
a) 2 b) 4 c) 16 d) 8

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 not allowed as first character in valid variable name?
a) Digit b) Underscore c) Letter d) Dollar

5. 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

6. Which is not a basic data type in Java?


a) char b) long c) Letter 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.5 b) 3 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

10

You might also like