0% found this document useful (0 votes)
8 views4 pages

Java Basics: Multiple Choice Questions

Chapter 7 covers Java basics through multiple choice questions focusing on primitive data types, variable naming conventions, arithmetic operations, and Java syntax. It includes questions about the Java Virtual Machine, data types, comments, and operators. The chapter serves as an exercise to reinforce understanding of fundamental Java concepts.

Uploaded by

jatinbhetariya
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)
8 views4 pages

Java Basics: Multiple Choice Questions

Chapter 7 covers Java basics through multiple choice questions focusing on primitive data types, variable naming conventions, arithmetic operations, and Java syntax. It includes questions about the Java Virtual Machine, data types, comments, and operators. The chapter serves as an exercise to reinforce understanding of fundamental Java concepts.

Uploaded by

jatinbhetariya
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

Chapter 7 Java Basics

Multiple Choice Question


Textbook Exercise

(1) How many basic (primitive) data types are supported in Java?
(A) 2 (B) 4 (C) 8 (D) 16
(2) What is the default data type of floating point literal?
(A) int (B) long (C) float (D) double
(3) Which of the following is not allowed as first character in valid variable name?
(A) Underscore (_) (B) Digit (C) Letter (D) Dollar
($)
(4) Which of the following is not a basic data type in Java?
(A) char (B) long (C) byte (D) String
(5) What is the default value of boolean type data?
(A) null (B) true (C) false (D) 0
(6) What will be the result of arithmetic expression 7/2?
(A) 3 (B) 3.5 (C) 1 (D) 0
(7) What will be the result of arithmetic expression –7%2 ?
(A) –3 (B) –1 (C) 1 (D) –3.5
(8) What will be the result of arithmetic expression –7.5%2 ?
(A) –3 (B) –1.5 (C) 1.5 (D) Error
(9) What sign is used for creating API documentation form the code?
(A) // (B) /* ..... */ (C) /** ..... */ (D) \\
(10) In Java, which of the following is not allowed as first character in valid variable
name?
(A) _ (Underscore) (B) Digit (C) Letter (D) $ (Dollar)
(11) What is known as when program written in Java are compiled in to machine
language for
a computer?
(A) Java Visible Machine (B) Java Virtual Machine
(C) Java View Modifier (D) Java Visible Modifier
(12) What is known as post decrement in Java when operator is used after variable
name?
(A) ++ (B) – – (C) == (D) =<
(13) By using which extension file java interpreter byte code executes?
(A) .java (B) .class (C) .txt (D) .html
(14) What kind of the primitive data types are provided in Java from the following?
(A) boolean (B) double (C) char (D) All of these
(15) What is the value of float data type in Java?
(A) Integer (B) Real (C) Character (D) Boolean
(16) In Java what will be the result of arithmetic expression –7.5%2?
(A) –3 (B) –1.5 (C) 1.5 (D) Error
(17) Java language is developed by which company?
(A) Sun Microsystem (B) Sun Java System
(C) Sun system (D) Sun Microsoft
(18) The machine language for the Java Virtual Machine is called what?
(A) Code Byte (B) Type code (C) Java Bytecode (D) Java code
(19) While creating Java what must be the same?
(A) folder name, file name (B) class name, extension
(C) class name, folder name (D) class name, file name
(20) When the program gets compiled without error, compiler creates a file with
which
extension ?
(A) .comp (B) .txt (C) .java (D) .class
(21) 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 class (*.exe) (B) Java textcode (*.txt)
(C) Java Bytecode (*.class) (D) Java typecode (*.obj)
(22) Which of the following is right way to define variable?
(A) $age (B) discount rate (C) 4youpeople (D)
%discount
(23) String literals is a sequence of characters enclosed in which quotes?
(A) ‘ ’ (B) “ ” (C) ( ) (D) { }
(24) Which of the two symbols are used in the conditional operator in Java?
(A) : and * (B) # and ? (C) ? and : (D) / and ?
(25) 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
(26) Java supports how many primitive data types?
(A) 3 (B) 8 (C) 4 (D) 7
(27) Which of the following data type is used for real numbers?
(A) short (B) char (C) long (D) double
(28) In Java, the text written in /* ..... */ is considered as what?
(A) Method (B)Comment (C) Function (D) Variable
(29) 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
(30) The definition of the method (function) in Java consists of function header and
the sequence of statement enclosed in which bracket?
(A) { } (B) < > (C) ( ) (D) [ ]
(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) From the following which methods are used to display results?
(A) [Link]() (B) [Link]()
(C) Both (A) and (B) (D) [Link]()
(33) In Java, the program is compiled without any error, which command is used to
execute it?
(A) Tools Go (B) Tools Run (C) Tools Build (D) Tools
Compile
(34) How many primitive data types are there in Java?
(A) 5 (B) 6 (C) 7 (D) 8
(35) Which sign is used to insert single line comment in Java?
(A) /* and */ (B) /** and */ (C) // (D) #
(36) From the following which is not logical operator in Java?
(A) AND (B) OR (C) NOT (D) Equal to
(37) From the following which is true syntax of conditional operator?
(A) <exp>=<exp1>=<exp2> (B) <exp>?<exp1>:<exp2>
(C) <exp>;<exp1>?<exp2> (D) <exp>=<exp1>:<exp2>
(38) In Java, at which level platform – independence is possible due to bytecode
interpreter?
(A) Browser (B) Source (C) Machine (D) Binary
(39) In Java, the machine language for Java Virtual Machine is known as which code?
(A) Java filecode (B) Java bytecode (C) Java intcode (D) Java
sourcecode
(40) To compile the java program we have to type what in front of source file name?
(A) javac [Link] (B) javac filename\ (C) javac [Link] (D) javac
[Link]
(41) If Java program is compiled without any error we can execute it in SciTE editor by
which
menu - option ?
(A) Compile Run Go (B) Edit Go (C) Tools Go (D) File Go
(42) What is the storage space for datatype float in Java?
(A) 1 byte (B) 2 byte (C) 4 byte (D) 8 byte
(43) In Java, for type boolean there are precisely two literals, which are they?
(A) Y and N (B) 0 and 1 (C) True and False (D) Yes and
No
(44) In Java, documentation comments begins and ends with which of the following?
(A) /** ..... */ (B) /* ..... */ (C) /* ..... / (D) //
(45) Arithmetic operators in Java, can be applied on which numeric data?
(A) short (B) float (C) byte (D) All of these
(46) In Java,which of the following is known as unary operators for increment and
decrement
operators?
(A) >== and <= (B) + and – (C) == and != (D) + + and - -
(47) Which of the following is considered as comparison operator in Java?
(A) = (B) / (C) % (D) !=
(48) In Java, logical operators are also called which of the following operators if they
operate on Boolean operands ?
(A) Assignment operator (B) Boolean operator
(C) Increment operator (D) Relational operator
(49) In Java, conditional uses which two symbols in expression to delimit three
operands?
(A) ? and * (B) . and : (C) ? and : (D) : and ;
(50) In Java, a block statement is a group of statements enclosed between which pair
of braces?
(A) [/ ..... /] (B) { } (C) ( ) (D) [ ]

You might also like