0% found this document useful (0 votes)
10 views12 pages

Java Basics Worksheet for Class 12

The document is a worksheet for a computer subject focused on Java Basics, designed for 12th-grade students and worth 100 marks. It consists of multiple-choice questions covering various topics related to Java programming, including data types, operators, control structures, and syntax. Each question is worth one mark, and the worksheet aims to assess students' understanding of fundamental Java concepts.

Uploaded by

dtlnp2008ms
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views12 pages

Java Basics Worksheet for Class 12

The document is a worksheet for a computer subject focused on Java Basics, designed for 12th-grade students and worth 100 marks. It consists of multiple-choice questions covering various topics related to Java programming, including data types, operators, control structures, and syntax. Each question is worth one mark, and the worksheet aims to assess students' understanding of fundamental Java concepts.

Uploaded by

dtlnp2008ms
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Subject: Computer Worksheet

Standard: 12 Marks: 100


Chapter: 7. Java Basics

Section - A
‣ Choose the correct option from those given below each question. (Each question carries 1 Marks) (100)
01. What is the use of data type?

d
A. Defines the size of a variable B. Type of values stored in a variable

an
C. (A) and (B) both D. To run the program

An
Ans
02. How are the data types in Java language?

ol
A. Dependent on other B. Machine independent C. Dependent on data D. All of these

ho
Ans

Sc
03. What is not available in Java ?
A. main B. typedef C. Bite code D. All of these
h
ig
Ans
H

04. ...... company developed Java.


e

A. Intel B. Oracle C. Sun Microsystems D. Microsoft


dg

Ans
le

05. Syntax rules use...... as basic vocabulary.


ow

A. variable, expressions B. statements, branches C. loop and method D. All of these


Kn

Ans
06. routine is executed first when program is executed in Java application.
A. main() B. void() C. (A) and (B) both D. none of these
Ans
07. Java is portable to a wide range of .......
A. small devices B. efficient devices C. hardware devices D. big devices
Ans
08. Real Number Literal is called .......
A. Floating Point Literal B. Real literal C. (A) or (B) D. None of these
Ans
09. In the standard method, integer part and fractional part are separated using
A. . B. ; C. , D. None of these
Ans
10. If another variable declared with same name within the scope of another variable then will be there in the
output.
A. value assigned first time to the variable is given in the output.
B. value assigned second(last) time to the variable is given in the output.

Page 1
C. error occurs.
D. program moves to the infinity mode.
Ans
11. What is the meaning of short hand operator q&& = p ?
A. q = q&&p B. q&&p = q C. p = q&&p D. p&&q= P
Ans
12. …………is not a valid variable.
A. balance B. Balance C. class D. date
Ans
13. compiler makes the bytecode file in Java language.......
A. jdk B. javac C. ecj D. None of these
Ans
14. If no match is found for any case in the switch statement, then………… is executed.

d
A. statement1 gets executed. B. default gets executed.

an
C. nothing is executed. D. (B) or (C)

An
Ans
15. Traditionally for. ......, first character is given in lower case.

ol
A. class B. variable C. method D. (B) and (C) both

ho
Ans

Sc
16. Java language can be called ...... language.
A. formatted language B. free formatted language
h
C. structured programming language D. none of these
ig

Ans
H

17. What syntax is used to declare multipl variables in Java ?


e
dg

A. <type- name> {variable - name}; B. <type- name> (variable - name);


C. <type- name><variable – name> D. <type- name> {variable-name};
le

Ans
ow

18. Match the following pairs.


Kn

Mean Escape code


(1) ANDing (i) ^
(2) OR (ii) | |
(3) XOR (iii)!
(4) NOT (iv) &&

A. (1→ iv), (2→ii),(3→ iii),(4 → i) B. (1→iv),(2→iii), (3→ ii),(4 → i)


C. (1 →iv), (2→ii),(3→i),(4→ iii) D. (1 →ii), (2→iii), (3→ i),(4→ iv)
Ans
19. The data types which are included in the system are called .......
A. Primary B. Primitive C. (A) or (B) D. (A) and (B) both
Ans
20. Which is the post-test statement ?
A. for B. while C. do...while D. switch
Ans
21. At...... level, platform-independece is possible due to bytecode interpreter.
A. Source Program B. Binary Level C. Hexa level D. None of these

Page 2
Ans
22. x = 6; a = 12.5; a % x; will give………….. output.
A. 2 B. 1 C. 0.5 D. 0
Ans
23. statement is used to change the control c program outside switch or loop.
A. continue B. stop C. break D. exit
Ans
24. ...... subroutine statements are used to display information of Java program to the user.
A. Function B. Method C. (A) or (B) D. (A) and (B) both
Ans
25. Java source file is saved with...... extension.
A. .doc B. . jav C. .Java D. .class
Ans

d
26. What is the meaning of 'public' with main()?

an
A. Subroutine can only be called from inside the program.

An
B. Subroutine can only be called from outside the program.
C. To display general information

ol
D. None of these.

ho
Ans

Sc
27. char data type has a character from………….. group of characters.
A. Unicode B. IEEE C. ASCII D. All of these
h
ig
Ans
H

28. In the scientific value 1.3e12,……………. represents the 10 exponent.


A. 1.3 B. e12 C. 3e D. 1.3e
e
dg

Ans
le

29. In…………. loop, statements are executed first the condition is checked.
ow

A. for B. WHIL C. do...while D. switch


Ans
Kn

30. Boolean values are not concerned with...............value.


A. character type B. any numeric value C. integer D. real
Ans
31. What is the default type of floating point literal?
A. float B. double C. char D. short
Ans
32. In C language, O is known as ...... in Boolean type.
A. true B. false C. zero D. constant value
Ans
33. In a variable name from second word first character of each word is given in upper case is known
as……………. .
A. camel case B. special case C. space case D. none of these
Ans
34. a = 12.5; b = 7.2; a % b; will give………..output.
A. 1 B. 5.3 C. 0.3 D. 6
Ans

Page 3
35. 8 % 3 will give ...... output.
A. 1 B. 2 C. 3 D. 4
Ans
36. Designers of Java choose to use.......
A. compilation B. interpretation
C. combination of compilation and D. (A) or (B)
Ans
37. What will be the result of arithmetic expression 7/2 ?
A. 3 B. 3.5 C. 1 D. 0
Ans
38. In the scientific method…………….. character is used.
A. e B. E C. t D. (A) or (B)
Ans

d
39. ...... is very similar to C++ language.

an
A. C B. FORTRAN C. COBOL D. Java

An
Ans
40. What is Java ?

ol
A. A scripting language B. Object oriented programming language

ho
C. File oriented language D. Structured programming language

Sc
Ans
41. What is the default value in byte data type?
h
A. 1 B. 0 C. 128 D. 255
ig
H

Ans
42. What is the use of comparison operator ?
e
dg

A. To make mathematical process


B. To compare values of integer type and char type
le

C. (A) and (B) both


ow

D. There is no operator like this in Java.


Kn

Ans
43. compiler makes the bytecode file in Java language.......
A. jdk B. javac C. ecj D. None of these
Ans
44. ………….. is the conditional operator.
A. Unary Operator B. Ternary Operator C. Bernary Operator D. None of these
Ans
45. What type of control structures are there in Java ?
A. loops B. branches C. (A) and (B) both D. Tree
Ans
46. How many logical operators are there in Java?
A. 3 B. 4 C. 5 D. 2
Ans
47. S = 10; S=S+ 2; S = 22; What will be the value of S?
A. 10 B. 12 C. 22 D. no output
Ans

Page 4
48. How to execute the program in SciTE editor?
A. Tools→ Go B. Tools→ Run C. Option→ Go D. Option → Run
Ans
49. If different types of tasks are there based on different values of a variable or the expression then should be
used.
A. if statement B. for statement C. switch statement D. all of these
Ans
50. In C language, non zero value is known as .......
A. true B. false C. zero D. constant value
Ans
51. Which is the pre-test loop?
A. for B. while C. (A) and (B) both D. do...while
Ans
52. ……….is the true syntax for declaring a variable.

d
an
A. <type name> {variable [= <value>,]}; B. <type name> {variable names};
C. (A) or (B) D. <type name> <variable - names>

An
Ans

ol
53. ...... code is faster to execute.

ho
A. Machine B. Native C. Panic D. Gative
Ans
54. Minimum how many classes are required in Java program?
Sc
h
A. 2 B. 3 C. 4 D. 1
ig
Ans
H

55. ................is not the logical operator.


e
dg

A. AND B. XOR C. OR D. EOF


Ans
le
ow

56. In the switch-statement what should be the type of test expression ?


A. byte B. short or int C. char D. All of these
Kn

Ans
57. In which range of values will be stored in unsigned integer ?
A. 0 to 2b-1 B. 0 to 2b-1 C. 0 to 2b-1+1 D. 0 to 2b-1
Ans
58. Traditionally for ......, first character is given in upper case.
A. class B. variable C. camel case D. method
Ans
59. ...... program is made of many classes.
A. C B. C++ C. Java program D. FORTRAN
Ans
60. …………file is also called byte code file.
A. [Link] B. [Link] C. [Link] D. [Link]
Ans
61. What is the default value of boolean type data?
A. null B. true C. false D. 0
Ans

Page 5
62. In which data type storage space is of 4 bytes?
A. int B. float C. (A) and (B) both D. char
Ans
63. ……………….is not primitive of Java.
A. class B. long C. float D. char
Ans
64. The textual data is given in symbol in [Link].
A. ('') (Single quote) B. ("") (Double quote) C. (##) (Hash sign) D. None of these
Ans
65. Statement is the example of ...... control structure.
A. branching B. decision C. all of these D. selective
Ans
66. In character literal, is used as escape character.

d
A. / (forward slash) B. / (back slash)

an
C. escape key D. %28double%20back%20slash

An
Ans
67. If numeric literal is preceded with...... then it 124 becomes octal value.

ol
A. L B. I C. OX D. O

ho
Ans

Sc
68. ....... can to be done in comment line.
A. Nesting B. Comment within another comment
h
C. (A) or (B) D. Comment line can not be written
ig
H

Ans
69. At ....... level, Java's primitive data types have consistent sizes across all development platforms.
e
dg

A. Source Program B. Binary Level C. Hexa levelb D. None of these


le

Ans
ow

70. method can only display information to the user.


A. [Link] B. [Link] C. [Link] D. [Link]
Kn

Ans
71. What will be the output of (x == 0) ^ (y == 0)?
A. true B. false C. error D. No output
Ans
72.
Match the following pairs.

Data type Storage Space


(1)char (i) 2 byte
(2) boolean (ii) 4 byt
(3) float (iii) 8 bytee
(4) double (iv) 1 byte

A. (A→i), (2→ iv), (3→ iii), (4 → i) B. (1→ iv), (2→ ii), (3→ iii), (4 → i)
C. (1→ ii), (2→ iv), (3→ i), (4 → iii) D. (1→ i), (2→ iv), (3→ ii),(4 → iii)
Ans
73. "1.2F" means………..
A. 1.2 literal is of float type B. 1.2 literal is of double type

Page 6
C. it is a real number D. all of these
Ans
74. What is the format of typecast?
A. (<data-type>) <expression> B. (datatype) (expression)
C. data <expression> D. <datatype> <expression>
Ans
75. The body of Java program is included in routine.
A. main() B. body() C. display() D. void(0)
Ans
76. …………is used to get Boolean result of an expression.
A. Comparison Operator B. Arithmetic Operator C. Logical Operator D. Conditional Operator
Ans
77. …………… is used to mention one line comment.

d
A. / B. download C. \ D. download

an
Ans

An
78. 25.8 % 7 will give…………… output.
A. 3 B. 4.8 C. 4 D. 5

ol
Ans

ho
79. ...... is called the assignment operator.

Sc
A. = B. == C. != D. = !
Ans
h
ig
80. The name used to store the data in the memory is known as…………… .
H

A. string B. float C. word D. double


e

Ans
dg

81. Control structure "Branches" can also called……….. .


le

A. loops B. selective structure C. (A) or (B) D. Tree


ow

Ans
Kn

82. Bytecode file has ...... extension.


A. java B. jdk C. class D. javac
Ans
83. x = 6; y = 4; x % y; will give…………output.
A. 1 B. 2 C. 0 D. 3
Ans
84. can also be used only with one operand.
A. + B. - C. * D. (A) and (B) both
Ans
85. Which sentence is true about Java language?
A. It is an object oriented language
B. It was developed in 1991 by Sun Microsystems
C. It can work at source level and binary level
D. All of these
Ans
86. When Java program is sent to interpreter, it……….. goes to method first.
A. main() B. body0 C. display() D. none of these

Page 7
Ans
87. Which sentence is false related for JVM?
A. Programs written in Java are compiled into machine language for a computer that doesn't really exist.
B. Java Bytecode interpreter are same for each type of computer.
C. Java binary files are actually in bytecode form.
D. Java byte code are not fixed for a processor or any operating system.
Ans
88. How many basic (primitive) supported in Java?
A. 2 B. 4 C. 8 D. 16
Ans
89. How to compile Java source file in SciTE editor?
A. Option-> Compile B. Tools → Compile C. Edit→ Compile D. File→ Compile
Ans
90. How many primitive data types are there Java language?

d
an
A. 5 B. 7 C. 8 D. 6

An
Ans
91. x = 10; y = 4+ ++x; then x =……….. and y =…………

ol
A. 10, 14 B. 11, 15 C. 11, 14 D. 10, 11

ho
Ans

Sc
92. ..........is the syntax of ternary Operator.
A. <boolean expression>: <expression 1>:<expression2>
h
B. <boolean - expression>? <expressionl> <expression2>
ig
C. <boolean - expression>? <expression1>:<expression2>
H

D. <boolean - expression>: <expression1>?<expression2>


e

Ans
dg

93. …………….. is used to represent octal values.


le

A. 0 to 7 B. 1 to 8 C. 8 D. None of these
ow

Ans
Kn

94. Java language uses.............characters.


A. Unicode B. ASCII C. Octal D. Binary
Ans
95. Logical operators are known as
A. boolean operator B. comparison operator C. arithmetic operator D. conditional operator
Ans
96. Block statements are written within……………. brackets.
A. "" and "" B. "{" and "}" C. "(" and ")" D. "<" and ">"
Ans
97. The repetition of the statements till condition is satisfied is called…………
A. loops B. branches C. (A) and (B) both D. Tree
Ans
98. In which data type value is counted as per Unicode number?
A. Integer B. char C. double D. float
Ans
99. How many looping structures are there in Java?

Page 8
A. 3 B. 4 C. only one D. 2
Ans
100. How are the basic arithmetic operators in Java ?
A. Binary B. Octal C. Hexadecimal D. Decimal
Ans

d
an
An
ol
ho
Sc
h
ig
H
e
dg
le
ow
Kn

Page 9
ANSWERS

Subject: Computer Worksheet


Standard: 12 Marks: 100
Chapter: 7. Java Basics

Section - A

‣ Choose the correct option from those given below each question. (Each question carries 1 Marks) (100)
01. (A) and (B) both
02. Machine independent
03. typedef
04. Sun Microsystems
05. All of these
06. main()

d
an
07. hardware devices
08. Floating Point Literal

An
09. .

ol
10. error occurs.

ho
11. q = q&&p
12. class

Sc
13. javac h
14. (B) or (C)
ig
15. (B) and (C) both
H

16. free formatted language


e

17. <type- name> {variable - name};


dg

18. (1 →iv), (2→ii),(3→i),(4→ iii)


le

19. (A) or (B)


ow

20. do...while
21. Binary Level
Kn

22. 0.5
23. stop
24. (A) or (B)
25. .Java
26. Subroutine can only be called from outside the program.
27. Unicode
28. e12
29. do...while
30. any numeric value
31. double
32. false
33. camel case
34. 5.3
35. 2
36. combination of compilation and
37. 3.5
38. (A) or (B)

Page 10
39. COBOL
40. Object oriented programming language
41. 0
42. To compare values of integer type and char type
43. javac
44. Ternary Operator
45. (A) and (B) both
46. 4
47. 22
48. Tools→ Go
49. switch statement
50. true
51. (A) and (B) both
52. (A) or (B)

d
53. Native

an
54. 1

An
55. EOF
56. All of these

ol
57. 0 to 2b-1

ho
58. class

Sc
59. Java program
60. [Link]
h
ig
61. false
H

62. (A) and (B) both


e

63. class
dg

64. ("") (Double quote)


le

65. all of these


ow

66. / (back slash)


67. O
Kn

68. (A) or (B)


69. Source Program
70. [Link]
71. true
72. (1→ i), (2→ iv), (3→ ii),(4 → iii)
73. 1.2 literal is of float type
74. (<data-type>) <expression>
75. main()
76. Arithmetic Operator
77. download
78. 4.8
79. =
80. string
81. selective structure
82. class
83. 2
84. (A) and (B) both

Page 11
85. All of these
86. main()
87. Java Bytecode interpreter are same for each type of computer.
88. 8
89. Tools → Compile
90. 8
91. 11, 15
92. <boolean - expression>? <expression1>:<expression2>
93. 0 to 7
94. Unicode
95. boolean operator
96. "{" and "}"
97. loops
98. char

d
99. 4

an
100. Binary

An
ol
ho
Sc
h
ig
H
e
dg
le
ow
Kn

Page 12

Common questions

Powered by AI

The Java compiler converts the source code into bytecode, the standard form of Java programs. This bytecode is then interpreted by the Java Virtual Machine (JVM), which is platform-specific, ensuring Java's 'write once, run anywhere' capability. This two-stage process combines both compilation and interpretation, balancing performance and cross-platform compatibility .

Java is popular due to its object-oriented nature, platform independence, and portability. It operates at both source and binary levels, thanks to its bytecode interpreter, which allows the software to run on any device that has a Java Virtual Machine (JVM). This makes Java a versatile choice for various applications, from web development to mobile and emerging IoT platforms .

Bytecode serves as an intermediary language between Java source code and the machine code of the host device, allowing Java applications to run on any platform with a JVM. This is crucial for portability, as the same program can be executed identically across various platforms without modification. Furthermore, bytecode compilation is an efficient process, optimizing runtime performance by allowing JVMs to execute common instructions quickly .

Java requires explicit declaration of data types, which helps catch errors at compile time by ensuring variables are used consistently. This strong typing system contributes to program safety by preventing illegal operations on data and improving code readability. The JVM verifies type correctness during execution, further enhancing error management by catching potential runtime errors early .

Control structures such as loops (for, while, do...while) and branches (if, switch) enable dynamic and flexible code logic, allowing programs to respond adaptively to input and conditions. This enhances functionality by enabling iteration over collections, conditional execution, and managing complex decision-making processes, making programs more efficient and adaptable to varying operational requirements .

Java ensures platform independence through the use of Java bytecode, which abstracts the code from the hardware specifics of the host machine. The Java Virtual Machine (JVM) on each platform interprets this bytecode, which allows Java applications to run on any device with a compatible JVM. This is vital for enterprise environments requiring cross-platform applications, reducing the overhead of developing platform-specific software .

Java's simplicity and ease of use are largely due to its clear syntax, familiarity to those with experience in languages like C/C++, and extensive libraries that simplify complex tasks. These features, along with ample documentation and community support, make it accessible for beginners, contributing to its widespread adoption in education and industry despite its complexity in advanced use cases .

Java differs from C++ in that it is strictly object-oriented and doesn't support standalone functions or global variables, focusing instead on classes and objects to structure code. Unlike C++, Java manages memory automatically with garbage collection, reducing errors related to memory management and improving reliability. This can significantly impact software development by enhancing code maintainability and security .

Logical operators in Java (&&, ||, !) are used to form compound boolean expressions and control flow within decision-making constructs. Unlike arithmetic or comparison operators, which are applied to numeric or comparable values, logical operators strictly evaluate boolean expressions to return true or false. This supports complex program logic by allowing precise control over flow and execution paths, a foundational element of robust software .

The `main()` method serves as the entry point for Java applications, where the program begins execution. This method is crucial because it sets the initial context for the runtime, initializing any necessary states or settings and invoking other methods necessary for program operations. Its standardized syntax (`public static void main(String[] args)`) ensures consistency across different applications .

You might also like