Week-01 - Assignment
Week-01 - Assignment
PROGRAMMING IN JAVA
Assignment 1
TYPE OF QUESTION: MCQ
Number of questions: 10 Total mark: 10 × 1 = 10
QUESTION 1:
Which of the following is NOT a primitive data type in Java??
a. int
b. boolean
c. String
d. char
Correct Answer: c
Detailed Solution:
QUESTION 2:
Consider the following program.
Detailed Solution:
Range of byte data in java is -128 to 127. But the byte data type in java is cyclic in nature.
___________________________________________________________________________
QUESTION 3:
Which of the following concept that Java doesn’t support?
a. inheritance
b. encapsulation
c. pointer
d. array
Correct Answer: c
Detailed Solution:
a. import
b. super
c. method
d. class
Correct Answer: c
Detailed Solution:
Here, import, super and class are reserved keywords in Java, which cannot be used for naming a
variable or class.
______________________________________________________________________
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 5:
Consider the following program.
Correct Answer: a
Detailed Solution:
______________________________________________________________
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 6:
Match the following java terms with their descriptions?
Detailed Solution:
Option a is correct.
______________________________________________________________________
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 7:
Consider the following program.
Correct Answer: c
Detailed Solution:
This will give compile error - “Lossy conversion from int to short”.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
QUESTION 8:
What is the output of the following code ?
a. null
b. true
c. false
d. 1
Correct Answer: c
Detailed Solution:
Test by run.
_____________________________________________________________________
QUESTION 9:
Which program is used to compile Java source code into bytecode?
a. javap
b. javac
c. java
d. javad
Correct Answer: b
Detailed Solution:
The JDK includes a tool, ‘javac’ that compiles from Java source code to a target of Java bytecodes.
The program ‘java’ is used to execute Java bytecode. Note that there is no program like ‘javap’
and ‘javad’.
NPTEL Online Certification Courses
Indian Institute of Technology Kharagpur
_____________________________________________________________________
QUESTION 10:
Consider the following program.
Correct Answer: a
Detailed Solution:
******