100% found this document useful (1 vote)
348 views20 pages

Java MCQS

1. The document contains a series of multiple choice questions about Java concepts. It covers topics like data types, primitive types, literals, comments, compilers, bytecode, JVM, JRE, and more. 2. The questions have a single correct answer out of 4 options to choose from. 3. The questions are testing the reader's understanding of fundamental Java concepts through multiple choice questions with definitive right and wrong answers.

Uploaded by

M Husnain Shahid
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
100% found this document useful (1 vote)
348 views20 pages

Java MCQS

1. The document contains a series of multiple choice questions about Java concepts. It covers topics like data types, primitive types, literals, comments, compilers, bytecode, JVM, JRE, and more. 2. The questions have a single correct answer out of 4 options to choose from. 3. The questions are testing the reader's understanding of fundamental Java concepts through multiple choice questions with definitive right and wrong answers.

Uploaded by

M Husnain Shahid
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 20

Java MCQS.

Which of the following is TRUE?

1. In java, an instance field declared public generates a compilation error

2. int is the name of a class available in the package java.lang

3. Instance variable na mes may only contain letters and digits

4. A class has always a constructor (possibly automatically supplied by the java compiler).

2. A constructor

1. must have the same name as the class it is declared within.

2. is used to create objects.

3. may be declared private

4. A, B and C

3. Which of the following may be part of a class definition?

1. instance variables

2. instance methods

3. constructors

4. all of the above

4. What is different between a Java applet and a Java application?

1. An application can in general be trusted whereas an applet cant


2. An applet must be executed in a browser environment

3. An applet is not able to access the files of the computer it runs on

4. A, B, and C

5. What is byte code in the context of Java?

1. The type of code generated by a Java compiler

2. The type of code generated by a Java Virtual Machine

3. It is another name for a Java source file

4. It is the code written within the instance methods of a class

6. What is garbage collection in the context of Java?

1. The operating system periodically deletes all of the java files available on the system

2. Any package imported in a program and not used is automatically deleted.

3. When all references to an object are gone, the memory used by the object is automatically
reclaimed

4. The JVM checks the output of any Java program and deletes anything that doesnt make
sense

7. JDK stands for

1. Java Debugging Kit

2. Java Developers Kit


3. None of these

4. Java Decompilation Kit

8. JVM is a

1. Debugger

2. Assembler

3. Interpreter

4. Compiler

9. Bytecode is given as input to

1. JRE

2. linker

3. JVM

4. Assembler

10. Output of Java Compiler is

1. Non executable code

2. Executable code

11. Output of Java Compiler is executable

1. true

2. false
12. Bytecode is a set of highly optimizable code. True or false

1. true

2. false

13. The JVM needs to be implemented for each platform

1. true

2. false

14. JVM will differ from platform to platform but still all understand the Same Java Bytecode

1. true

2. false

15. The compiler and other java development tools reside in _________ sub-folder.

1. jre

2. bin

3. docs

4. demo

16. The library containing the files needed to integrate Java with programs written in other languages
resides inside following sub folder.

1. jre

2. bin

3. include
4. lib

17. We can set class path of java by setting following variable.

1. javapath

2. class

3. path

4. java

18. Variable path in Windows Operating System is called as ________.

1. Environment Variable

2. Local Variable

3. Instance Variable

4. Global Variable

19. Environment Variable can be set by right clicking __________ icon and then clicking on
Properties menu in Windows OS.

1. Internet Explorer

2. Recycle Bin

3. Control Panel
4. My Computer

20. Arrange the following statements in correct order. 1. Running the java command Statement. 2.
Main method of that class is executed Statement. 3. JRE is loaded along with the class you specify.

1. Statement: 2 1 3

2. Statement: 1 3 2

3. Statement: 1 2 3

4. Statement: 3 2 1

21. We can compile java program with following command

1. java-version

2. javac

3. jre

4. java

22. Class file must have extension ______.

1. .sample.class

2. .class

3. .cls

4. .java

23. The name of the class file is created automatically when you compile the program with the javac
command.
1. true

2. false

24. _______ is a compiled Java program that can be executed by the _______ command.

1. class file & javac

2. class file & java

3. source file & java

4. source file & javac

25. Java source code is compiled into _______.

1. Bytecode

2. .exe

3. Source code

4. .obj

26. Which of the tool is used to compile java code?

1. javac

2. jar

3. java

4. javadoc
27. Which of the following tool used to execute java code.

1. javadoc

2. java

3. rmic

4. javac

28. Which of the following is used to interpret and execute Java Applet Classes hosted by HTML.

1. appletshow

2. appletscreen

3. appletviewer

4. appletwatcher

29. HTML based Java Documentary help can be accessed using

1. none of these

2. javadoc

3. javahelp

4. javamanual

30. jar stands for ________.

1. none of these

2. Java Archive
3. Java Application Runner

4. Java Archive Runner

31. Which of the following is used to see the details of the compilation

1. javac -detail TestExample.java

2. javac -verbose TestExample.java

3. None of these

4. javac -debug TestExample.java

32. Which of the following is not a keyword in Java.

1. boolean

2. assert

3. finalize

4. abstract

33. Which of the following is not a keyword in Java.

1. strictfp

2. instanceof

3. emun

4. transient
34. We can write comment like this jn Java Programming: /* /* comment 1 */ comment 2 */

1. true

2. false

35. What is Literal in Java Programming?

1. Source code representation of a fixed value

2. special type of class

3. special type of data type

4. none of these

36. It is possible to assign a literal to a variableof a primitive type.

1. False statement

2. True statement

37. boolean result = true; Which type of literal is assigned to the variable result?

1. boolean

2. char

3. string

4. bool

38. Which type of literal is written in pair of single quote?

1. float
2. boolean

3. integer

4. character

39. An integer literal is of type long if and only if it has suffix - ______ in Java programming.

1. L

2. D

3. O

4. F

40. ____ literal is used to create values of the integral types byte, short, int and long.

1. Double

2. Integer

3. Byte

4. Long

41. Number system whose digits consists of the numbers 0 through 9 is called as ____________.

1. Decimal Number System

2. Binary Number System

3. Octal Number System


4. Hexa Decimal Number System

42. Question 244 Hexa Decimal Numbers are having base _________.

1. 10

2. 8

3. 2

4. 16

43. In Java programming you can create binary literal in ______________.

1. Java SE 5 and later

2. Java SE 1 and later

3. Java SE 7 and later

4. Java SE 6 and later

44. Integer literal containing value "F" comes under _______ system.

1. Octal number

2. Binary number

3. None of these

4. Hexa Decimal Number

45. Following example of Nested Comments is allowed in Java Programming Language. // /*Nesting
of Comment */
1. true

2. false

46. Single line comments starts with _____ in Java.

1. //

2. /* *

3. /*

4. none of these

47. Folllowing is the human readable in Java Programming Language.

1. .class

2. .obj

3. .jar

4. .java

48. Which of the following converts human readable file into platform independent code file in Java?

1. JRE

2. Compiler

3. JVM
4. appletwatcher

49. Platform independent code file created from source file ins understandable by ________.

1. JRE

2. Applet

3. JVM

4. Compiler

50. JVM stands for _____.

1. Java Virtual Memory

2. Java Virtual Mechanism

3. Java Virtual Management

4. Java Virtual Machine

51. JRE stands for _____.

1. Java Reply Engine

2. Java Runtime Engine

3. Java Running Engine

4. Java Runtime Environment

52. Which of the following is considered as platform independent code?

1. Source Code
2. Compiled code

53. Java is called as platform independent language. Do you agree with this statement?

1. Yes

2. No

54. We can run same java program on different environment with same JDK version.

1. true

2. false

55. Java has ______ primtive types of data.

1. 9

2. 8

3. 6

4. 7

56. Which of the following is smallest integer data type?

1. Bytecode

2. int

3. short

4. long

57. Which of the following is not a primitive data type?


1. Internet Explorer

2. enum

3. short

4. byte

58. Integer Data type does not include following primitive data type.

1. long

2. double

3. short

4. byte

59. Which of the following data types comes under floating data types: 1.Float 2.Int 3.Double 4.Byte
5.Long

1. 1 and 2

2. 1 and 3

3. 2 and 3

4. 4 and 5

60. Character data type cannot store following value.


1. Special character

2. string

3. letter

4. digit

61. Byte variables are declared by use of the _______ keyword (Using primitive data type)

1. Bytes

2. Byte

3. byte

4. bytes

62. Range of Byte Data Type is ______.

1. -127 to 128

2. -128 to 256

3. -128 to 255

4. -128 to 127

63. In order to fetch stream of data from network of file, following data type is used _______.

1. int

2. byte

3. char
4. double

64. What is the size of integer in Java Programming.

1. 2 Bytes

2. 8 Bytes

3. 3 Bytes

4. 4 Bytes

65. Currently Java is owned by ______.

1. Oracle

2. Sun

3. Microsoft

4. Apple

66. IDE stands for _________.

1. Integrated Development Environment

2. Internationalized Development Environment

3. Indian Develolpment Environment

4. none of these

67. We can write sophisticated Java Programs using ________.


1. IDE

2. Normal Simple Textpad

3. Command prompt

4. none of these

68. Which of the following is not an IDE

1. Oracles Java Studio Creator

2. ntelliJ IDEA

3. Eclipse

4. All are IDEs

69. Front end applications which includes GUI are created using

1. IDE

2. Dos

3. Compiler

4. JVM

70. We can also use command line tool to run java application.

1. true

2. false
71. Which of the following is not a Java Code Editor?

1. Ms-Word

2. Netbeans

3. Notepad ++

4. Edit +

72. Eclipse is free open-source Integrated development environment.

1. true

2. false

73. We can run java program directly from the IDE using shortcut.

1. true

2. false

74. We can debug java program using IDE.

1. true

2. false

You might also like