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

Java History and Basic MCQ

The document consists of a series of multiple-choice questions and answers related to Java programming, covering topics such as Java's inventor, characteristics, components, data types, and coding conventions. Key concepts include the platform independence of Java, the role of the Java Development Kit (JDK), and the significance of bytecode. It also addresses common programming practices and the structure of Java programs, including the main method and comments.

Uploaded by

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

Java History and Basic MCQ

The document consists of a series of multiple-choice questions and answers related to Java programming, covering topics such as Java's inventor, characteristics, components, data types, and coding conventions. Key concepts include the platform independence of Java, the role of the Java Development Kit (JDK), and the significance of bytecode. It also addresses common programming practices and the structure of Java programs, including the main method and comments.

Uploaded by

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

1. Who invented Java Programming?

a) Guido van Rossum


b) James Gosling
c) Dennis Ritchie
d) Bjarne Stroustrup
Answer: b
2. Which statement is true about Java?
a) Java is a sequence-dependent programming language
b) Java is a code dependent programming language
c) Java is a platform-dependent programming language
d) Java is a platform-independent programming language
Answer: d
3. Which component is used to compile, debug and execute the java programs?
a) JRE
b) JIT
c) JDK
d) JVM
Answer: c
4. What is the extension of java code files?
a) .js
b) .txt
c) .class
d) .java
Answer: d
5. What is the extension of compiled java classes?
a) .txt
b) .js
c) .class
d) .java
Answer: c
6.Which of the following is a valid long literal?
a) ABH8097
b) L990023
c) 904423
d) 0xnf029L
Answer: (d)
7.JDK stands for ____.
a) Java development kit
b) Java deployment kit
c) JavaScript deployment kit
d) None of these
Answer: a
8.JRE stands for ___.
a) Java run ecosystem
b) JDK runtime Environment
c) Java Runtime Environment
d) None of these
Answer: c
9.Which class in Java is used to take input from the user?
a) Scanner
b) Input
c) Applier
d) None of these
Answer: a
10.Every statement in Java language should end with a?
a) Dot or Period
b) Comma
c) Semicolon
d) Colon
Answer: c
11. What is the need to mention "static" before main method?
a) To call main method with creating an object of class
b) To make main method as class method common to all instances
c) Both A and B
d) None of the above
Answer: b
12.What is the use of Access modifier "public" in main( ) method?
a) To hide the main method from misuse
b) To call the main method outside of Class or Package by JVM
c) To protect main method
d) None of the above
Answer: b
13.Choose a Single Line Comment in Java Language below?
a) //Some comments
b) Some comments//
c) /*Some comments*/
d) */Some comments/*
Answer: a
14.Name of a Class, Variable, Method or an Interface in Java language is called?
a) Argument
b) Value
c) Identifier
d) None of the above
Answet: c
15.When an expression consists of int, double, long, float, then the entire
expression will get promoted into a data type that is:
a) float
b) double
c) int
d) long
Answer: (b)
16.Which of the following declarations does not compile?
a) double num1, int num2 = 0;
b) int num1, num2;
c) int num1, num2 = 0;
d) int num1 = 0, num2 = 0;
Answer: a
17.A compiler converts the Java program into an intermediate language
representation called ___
a) bytecode
b) byte
c) byteclass
d) bytejava
Answer: a
18.What is the return type of program’s main( ) method?
a) void main()
b) int
c) void
d) no return type
Answer: c
19.What is byte code in the context of Java?
a) The type of code generated by a Java compiler.
b) The type of code generated by a Java Virtual Machine.
c) It is another name for a Java source file.
d) It is the code written within the instance methods of a class.
e) It is another name for comments written within a program.
Answer: a
20.Identify, from among the following, the incorrect variable name(s).
a) _theButton
b) $reallyBigNumber
c) 2ndName
d) CurrentWeatherStateofplanet
e) my2ndFont.
Answer: c
21.Which of the following is not a primitive data type in Java?
a) int
b) float
c) boolean
d) String
Answer :d
22.What is the range of values that can be stored in a byte data type in Java?
a) -128 to 127
b) -32768 to 32767
c) -2147483648 to 2147483647
d) None of the above
Answer :a
23.Java programs are …….. independent.
a) platform
b) procedural
c) high level
d) Secure
Answer:a
24.___ is the ability of a Java application to perform multiple tasks at the same
time.
a) Multiprogramming
b) Multithreading
c) Multiprocessing
d) Multitasking
Answer: b
25.Which is the first line to trigger a compiler error?
a) double d1 = 5f; // p1
b) double d2 = 5.0; // p2
c) float f1 = 5f; // p3
d) float f2 = 5.0; // p4
a) p1
b) p2
c) p3
d) p4
Answer:d
26.Observe the following code snippet and choose the correct option.
byte b = 10; // line 1
b = b * 10; // line 2
a) Lines 1 and 2 both execute without any error.
b) Because of line 2, the code will not compile.
c) Because of line 1, the code will not compile.
d) None of the above
Answer:b
27.A valid Identifier or name in Java language can start with which character?
a) a-z, A-Z
b) $, _
c) 0-9
d) A and B
Answer: d
28.What is the entry point of a program in Java?
a) main() method
b) The first line of code
c) Last line of code
d) main class
Answer: a
29.Multiline comment is created using ___.
a) //
b) /* */
c) <!-- -- >
d) All of these
Answer: b
30.What makes the Java platform independent?
a) Advanced programming language
b) It uses bytecode for execution
c) Class compilation
d) All of these
Answer: b
31.Number of primitive data types in Java are?
a)5
b)6
c)7
d)8
ans : d
32.What is the size of float and double in java?
a)32 and 64
b)32 and 32
c)64 and 64
d)64 and 32

Ans : a
33.Which one of the following is not a Java feature?
a) Object-oriented
b) Use of pointers
c) Portable
d) Dynamic and Extensible

Ans : b
34.What is the original name of Java Programming language?
A) J++
B) C++
C) OAK
D) TEAK

Ans : C

35.Which company owns Java at present?


A) IBM
B) Microsoft
C) Sun Microsystems
D) Oracle

Ans : D
36. What is a Compiler?
A) A Compiler converts all instructions in one go.
B) A compiler converts source code to low-level code
C) Compilers work fast
D) All the above

Ans : D

37.Choose a correct statement about Java source files.


A) Java files are human readable
B) Java files contain Classes with Methods and Variables
C) Import statements import library Classes into our class
D) All the above

Ans :D

38.Byte code is the result of?


A) Compiling a Java file
B) Compiling a Class file
C) Interpreting a Java File
D) Interpreting a Class file

Ans :A

39.What is JVM ?
A) JVM is the confined memory area
B) All java programs run inside JVM memory
C) JVM provides security to the computer by giving controlled access to Files and
Memory on a computer
D) All the above

Ans :D

40.When was first Version of Java i.e Java 1.0 was released?
A) 1991
B) 1994
C) 1996
D) 1999

Ans :C

41.What is Portability offered by Java language?


A) Small code size easy to carry occupying less disk space
B) Generating suitable Byte Code for each machine by the Compiler
C) Ability to run the Byte on different machines producing the same behaviour and
output
D) Java does not actually provide portability

Ans : C

42.What is JIT in Java?


A) Java In Timer
B) Java In Time Thread
C) Just In Time Compiler
D) Just In Time Runnable

Ans : C

43.Choose the correct statement about Java?


A) JIT Compiler produces Byte Code from Java file.
B) JIT Compiler takes chunks of Byte Code as input and produces Executable code on
that particular machine.
C) JIT Compiler assists the actual JAVAC compiler to compile fast
D) None of the above

Ans : B

44.What happens in the absence of JIT Compiler in Java?


A) Byte code is produced slowly
B) Executable Code is produced slowly because of line by line Interpreting
C) Executable Code is produced without portability
D) None of the above

Ans : B

45.What is the Java command used to compile a java program from Command Line or
Command Prompt or CMD?
A) >java Hello.java
B) >javac Hello.java
C) >javacomp Hello.java
D) >javacmd Hello.java

Ans : B

46.What is the command used to Run a Java program form Command Line or Command
Prompt or CMD?
A) javac Hello
B) java Hello.class
C) java Hello
D) javac Hello.java

Ans : C

47.A function in C language is similar to what in Java language?


A) Method
B) Member
C) Variable
D) None of the above

Ans : A

48. In standalone Java applications, which method is mandatory?


A) main method
B) show method
C) display method
D) print method

Ans : A

49.Choose a correct version of Java Documentation Comment?


A)
/*
comments
*/
B)
/**
comments
*/
C)
/*
comments
**/
D)
/**
comments
**/

Ans :B
50.which among the following is not a Data Type in Java?
A) short
B) int
C) long double
D) double

Ans: C

You might also like