Programming in Java | NPTEL 2023 | Week 1 quiz solutions

This set of MCQ(multiple choice questions) will help you with the solutions of Programming in Java NPTEL Week 1 Quiz.

Overview: Programming in Java

With the growth of Information and Communication Technology, there is a need to develop large and complex software. In addition, those software should be platform independent, Internet enabled, easy to modify, secure, and robust. To meet this requirement object-oriented paradigm has been developed and based on this paradigm the Java programming language emerges as the best programming environment. Now, Java programming language is being used for mobile programming, Internet programming, and many other applications compatible to distributed systems.
This course aims to cover the essential topics of Java programming so that the participants can improve their skills to cope with the current demand of IT industries and solve many problems in their own filed of studies. 

Enroll NPTEL courses for FREE

Do you want to explore your knowledge or improve your skills at zero cost? If yes, then NPTEL is a very good option for you.
National Programme on Technology Enhanced Learning (NPTEL) is an Indian learning platform for university-level science, technology, engineering, and mathematics subjects. More than 900 active courses are available on NPTEL. And the good thing is you can enroll them in free.
Are you ready for this exciting journey to learn new skills? If yes, then for what you are waiting. Just read the complete step by step guide on “How to Register for NPTEL Online Courses for Free” and get yourself enrolled in any course of your interest.
All the required steps/points are made very clear with proper description and images in this guide. You have to just follow all the steps properly and you are good to go.

Course layout

Answers COMING SOON! Kindly Wait!

NOTE: You can check your answer immediately by clicking show answer button. Programming in Java NPTEL Week 1 Quiz Solutions” contains 10 questions.

Now, start attempting the quiz.

Programming in Java NPTEL Week 1 Quiz Solutions

Q1. Which of the following is NOT a primitive data type in Java?

a) int
b) boolean
c) String
d) char

Answer: c) String

Q2. Consider the following program.

public class Question{
    public static void main(String[] args) {
         byte x = 127;
         x++;
         ++x;
         System.out.print(x);
    }
}

What is the output of the above code?

a) 127
b) -127
c) 129
d) 2

Answer: b) -127

Q3. Which of the following concept that Java doesn’t support?

a) inheritance
b) encapsulation
c) pointer
d) array

Answer: c) pointer

Q4. Which of the following is not a keyword in java?

a) import
b) super
c) method
d) class

Answer: c) method

Q5. Consider the following program.

public class Question{
    public static void main(String[] args) {
           int[] x = {12, 20, 015};
           for(int i=0; i<x.length; i++){
                System.out.print(x[i] + " ");
           }
    }
}

What will be the output of the program if it is executed?

a) 12 20 13
b) 12 20 15
c) 12 20 015
d) 12 20 F

Answer: a) 12 20 13

Q6. Match the following java terms with their descriptions?
Choose the correct option.

a) A-1, B-2, C-3
b) A-2, B-3, C-1
c) A-3, B-2, C-1
d) A-3, B-1, C-2

Answer: a) A-1, B-2, C-3

Q7. Consider the following program.

public class Question{
     public static void main(String[] args) {
         short x = 20;
         x = x * 2;
         System.out.print(x);
     }
}

What will be the output of the program if it is executed?

a) 20
b) 2
c) Compiler error
d) 40

Answer: c) Compiler error

Q8. What is the output of the following code?

public class Question{
     public static void main(String[] args) {
         boolean x = true;
         boolean y = false;
         boolean z = (x==y);
         System.out.pritnln(z);
     }
}

a) null
b) true
c) false
d) 1

Answer: c) false

Q9. Which program is used to compile Java source code into bytecode?

a) javap
b) javac
c) java
d) javad

Answer: b) javac

Q10. Consider the following program.

public class Question {
     public static void main(String[] args) {
         int x = 5; 
         x *= (2+8);
         System.out.println(x);
     }
}

What will be the output of the program if it is executed?

a) 50
b) 10
c) Compiler error
d) 5

Answer: a) 50

Previous | Programming in Java NPTEL 2023 Week 1 Quiz Solutions

Q1. What is the incorrect statement about bytecode?

a) Java when compiles the source code, it converts it to bytecode
b) JVM (Java Virtual Machine) is an interpreter of bytecode
c) Bytecode is not portable and it needs to be compiled separately for each platform
d) JVM offers a protected environment which helps in enhanced safety for the system

Answer: c) Bytecode is not portable and it needs to be compiled separately for each platform

Q2. What is the output of the above code?

a) a
b) Compiler error due to line n1
c) Compiler error due to line n2
d) Print nothing

Answer: d) Print nothing

Q3. Which one of the following is not a primitive datatype?

a) byte
b) short
c) class
d) long

Answer: c) class

Q4. Which of the following is not a keyword in java?

a) final
b) super
c) integer
d) extend

Answer: c), d)

Q5. What will be the output of the program if it is executed?

a) 15-even-1
b) 15-odd-1
c) 15-even-
d) 15-odd-

Answer: b) 15-odd-1

Q6. Why does the error “javac is not recognized as an internal or external command” occur?

a) Path is not set for java
b) JDK is not correctly installed
c) .class file is not found
d) javac jar is missing from java library

Answer: a) Path is not set for java

Q7. Following is a piece of code where some parts of a statement is missing:
In the following, some option are given. You have to choose the correct option(s) for the argument in System.out.print() function to print the value 102.

a) nptel[nptel.length-2]+nptel[0]
b) nptel[0] + nptel[nptel.length-2]
c) “” + nptel[nptel.length-2] + nptel[0]
d) “” + nptel[0] + nptel[nptel.length-2]

Answer: a), b)

Q8. Which of the following concept that Java doesn’t support?

a) inheritance
b) serialization
c) goto
d) array

Answer: c) goto

Q9. The subsystem of JVM that is used to load class files is known as ____________.

a) Classloader
b) JRE
c) JDK
d) Compiler

Answer: a) Classloader

Q10. What is the value of total after executing the following code snippet?
int marks = 5;
int grace = 2;
int total = mark + (mark > 6 ? ++grace : –grace);

a) 6
b) 5
c) 4
d) 3

Answer: a) 6

Programming in Java NPTEL 2022 Week 1 Quiz Solutions

Q1. Consider the following program.

public class Question{
   public static void main(String args[]){
      for(int b=7; b>3; b-=5){
         System.out.print(b+++b);
      }
   }
}

What will be the output of the program if it is executed?

a) 15
b) 12
c) 14
d) 10

Answer: a) 15

Q2. Following is a piece of code where some parts of a statement is missing:
In the following, some options are given. You have to choose the correct option for the argument in System.out.print() function to print the first and the last but one characters in the array nptel.

a) nptel[nptel.length-2]+nptel[0]
b) nptel[0] + nptel[nptel.length-2]
c) “” + nptel[nptel.length-2] + nptel[0]
d) “” + nptel[0] + nptel[nptel.length-2]

Answer: d) “” + nptel[0] + nptel[nptel.length-2]

Q3. Consider the following program.
What will be the output of the program if it is executed?

a) Print the value of N!
b) Print the value of N(N+1)/2
c) Print the value of 1x3x5x…xN
d) Print the value of 1!x2!x3!x…xN!

Answer: a) Print the value of N!

Q4. Which of the following can be used for a variable name in Java?

a) byte
b) throw
c) this
d) extend

Answer: d) extend

Q5. Consider the following program.
What will be the output of the program if it is executed? Let N=10

a) 5
b) 20
c) 8
d) 10

Answer: c) 8

Q6. A platform is the hardware or software environment in which a program runs. Which of the following is/are Java platform components(s)?

a) HTML
b) Java Virtual Machine
c) Java Application Programming Interface (API)
d) HotJava

Answer: b), c)

Q7. What is the value returned by the method f() defined below?
public static int f(int x, int y) { return (x>y) ? y : x; }

a) The sum of x and y that is, x + y
b) The difference of x and y that is, x – y
c) The maximum of x and y that is, the larger value of x and y.
d) The minimum of x and y that is, the smaller value of x and y.

Answer: d) The minimum of x and y that is, the smaller value of x and y.

Q8. A Java file with extension ‘.class’ contains

a) Java source code
b) HTML tags
c) Java Byte code
d) A program file written in Java programming language

Answer: c) Java Byte code

Q9. Which of the following is used to find and fix bugs in the Java programs?

a) JVM
b) JRE
c) JDK
d) JDB

Answer: d) JDB

Q10. Consider the following program.
What will be the output of the program if it is executed?

a) Print first six even numbers.
b) Print first six odd numbers.
c) Print first five even numbers.
d) Print first six Fibonacci numbers.

Answer: d) Print first six Fibonacci numbers.

>> Next- Programming in Java Week 2 Assignment Solutions

Previous – Week 1 Quiz Solutions

Q1. Which of the following is not a Language Processor?

a) Assembler
b) Compiler
c) Interpreter
d) Fortran

Answer: d) Fortran

Q2. Which of the following is not a valid comment?

a) /** comment */
b) /* comment */
c) /* comment
d) // comment

Answer: c)

Q3. Consider the following program.

public class Question{
     public static void main(String args[]) {
        for(int a=2; a<3; a+=1) {
             system.out.print(a+++a);
        }
     }
}

What will be the output of the program if it is executed?

a) 5
b) 2
c) 4
d) 1

Answer: a) 5

Q4. Which of the following can be used for a variable name in Java?

a) boolean
b) final
c) finally
d) calloc

Answer: d) calloc

Q5. Consider the following program.

public class Question1{
     public static void main(String args[]){
         int arr[]={0, 1, 2, 3, 4, 5, 6, 7};
           for(int b=5; b>2; b-=2){
                 system.out.println(arr[--b]);
           }
     }
}

What will be the output of the program if it is executed?

a) 4
b) 2
c) 3
d) 5

Answer: a) 4

Programming in Java NPTEL 2022 Week 1 quiz Solutions

Q6. Following is a piece of code where some parts of a statement is missing:

public class Question3{
     public static void main(String args[]) {
         char nptel[]={'S', 'W', 'A', 'Y', 'A', 'M'};
         system.out.print(__________);
     }
}

In the following, some options are given. You have to choose the correct option for the argument in System.out.print() function to print the second and the last characters in the array nptel.

a) nptel[nptel.length] + nptel[1]
b) nptel[1] + nptel[nptel.length-1]
c) “” + nptel[1] + nptel[nptel.length-1]
d) “” + nptel[nptel.length-1] + nptel[1]

Answer: c) “” + nptel[1] + nptel[nptel.length-1]

Q7. What is the output of this program?

public class Question {
     public static void main(String args[])
     {
        int i=7;
        system.out.print(--i * 7);
     }
}

a) 20
b) 25
c) 42
d) 31

Answer: c) 42

Programming in Java NPTEL 2022 Week 1 Quiz solutions

Q8. Which of the following is used to find and fix bugs in the Java programs?

a) JVM
b) JRE
c) JDK
d) JDB

Answer: d) JDB

Q9. Which of the following is/are primitive data type(s) in Java?

a) int
b) String
c) Array
d) double

Answer: a), d)

Q10. When you compile a program written in the Java programming language, the compiler converts the human-readable source file into platform-independent code that a Java Virtual Machine can understand. What is this platform-independent code called?

a) Source code
b) Bytecode
c) Machine code
d) Opcode

Answer: b) Bytecode

Prevoius – Week 2 Assignment Solutions


DISCLAIMER: Use these answers only for the reference purpose. Quizermania doesn't claim these answers to be 100% correct. So, make sure you submit your assignments on the basis of your knowledge.

Nptel – Deep Learning assignment solutions

Social Networks nptel assignment answers

NPTEL answers: Programming in Modern C++

For discussion about any question, join the below comment section. And get the solution of your query. Also, try to share your thoughts about the topics covered in this particular quiz.

Leave a Comment

Your email address will not be published. Required fields are marked *