Thursday 5 May 2022

10 Java Programming (MCQs)

Java Programming (MCQs) 

1. Who invented Java Programming?

a) Guido van Rossum
b) James Gosling
c) Dennis Ritchie
d) Bjarne Stroustrup

Answer: b
Explanation: Java programming was developed by James Gosling at Sun Microsystems in 1995. James Gosling is well known as the father of Java.

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
Explanation: Java is called ‘Platform Independent Language’ as it primarily works on the principle of ‘compile once, run everywhere’.

3. Which component is used to compile, debug and execute the java programs?
a) JRE
b) JIT
c) JDK
d) JVM

Answer: c
Explanation: JDK is a core component of Java Environment and provides all the tools, executables and binaries required to compile, debug and execute a Java Program.

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

Answer: b
Explanation: Pointers is not a Java feature. Java provides an efficient abstraction layer for developing without using a pointer in Java. Features of Java Programming are Portable, Architectural Neutral, Object-Oriented, Robust, Secure, Dynamic and Extensible, etc.

5. Which of these cannot be used for a variable name in Java?
a) identifier & keyword
b) identifier
c) keyword
d) none of the mentioned

Answer: c
Explanation: Keywords are specially reserved words that can not be used for naming a user-defined variable, for example, class, int, for, etc.

6. What is the extension of java code files?
a) .js
b) .txt
c) .class
d) .java

Answer: d
Explanation: Java files have .java extension.

7. What will be the output of the following Java code?

  1.     class increment {
  2.         public static void main(String args[]) 
  3.         {        
  4.              int g = 3;
  5.              System.out.print(++g * 8);
  6.         } 
  7.     }

a) 32
b) 33
c) 24
d) 25

Answer: a
Explanation: Operator ++ has more preference than *, thus g becomes 4 and when multiplied by 8 gives 32.
output:

$ javac increment.java
$ java increment
32

8. Which environment variable is used to set the java path?
a) MAVEN_Path
b) JavaPATH
c) JAVA
d) JAVA_HOME

Answer: d
Explanation: JAVA_HOME is used to store a path to the java installation.

9. What will be the output of the following Java program?

  1. class output {
  2.         public static void main(String args[]) 
  3.         {
  4.             double a, b,c;
  5.             a = 3.0/0;
  6.             b = 0/4.0;
  7.             c=0/0.0;
  8.  
  9. 	    System.out.println(a);
  10.             System.out.println(b);
  11.             System.out.println(c);
  12.         } 
  13.     }

a) NaN
b) Infinity
c) 0.0
d) all of the mentioned

Answer: d
Explanation: For floating-point literals, we have a constant value to represent (10/0.0) infinity either positive or negative, and also have NaN (not a number for undefined like 0/0.0), but for the integral type, we don’t have any constant that’s why we get an arithmetic exception.

10. Which of the following is not an OOPS concept in Java?
a) Polymorphism
b) Inheritance
c) Compilation
d) Encapsulation

Answer: c
Explanation: There are 4 OOPS concepts in Java. Inheritance, Encapsulation, Polymorphism, and Abstraction.

Sunday 24 April 2022

MCQs on Computer Fundamentals

MCQs on Computer Fundamentals 


1. Who is the father of Computers?

a) James Gosling
b) Charles Babbage
c) Dennis Ritchie
d) Bjarne Stroustrup

Answer: b
Explanation: Charles Babbage is known as the father of computers. Charles Babbage designed and built the first mechanical computer and Difference Engine.

2. Which of the following is the correct abbreviation of COMPUTER?
a) Commonly Occupied Machines Used in Technical and Educational Research
b) Commonly Operated Machines Used in Technical and Environmental Research
c) Commonly Oriented Machines Used in Technical and Educational Research
d) Commonly Operated Machines Used in Technical and Educational Research

Answer: d
Explanation: The word COMPUTER is an abbreviation for the terms “Commonly Operated Machines Used in Technical and Educational Research”. The word COMPUTER also relates to the word COMPUTE which means to calculate. So initially, it was thought that a computer is a device that is used to perform calculations.

3. Which of the following is the correct definition of Computer?
a) Computer is a machine or device that can be programmed to perform arithmetical or logic operation sequences automatically
b) Computer understands only binary language which is written in the form of 0s & 1s
c) Computer is a programmable electronic device that stores, retrieves, and processes the data
d) All of the mentioned

Answer: d
Explanation: A computer is a machine or device that can be programmed to perform arithmetical or logic operation sequences automatically. The computer understands only binary codes (0s & 1s).

4. What is the full form of CPU?
a) Computer Processing Unit
b) Computer Principle Unit
c) Central Processing Unit
d) Control Processing Unit

Answer: c
Explanation: CPU stands for Central Processing Unit. CPU is the part of a computer system that is mainly referred as the brain of the computer.

5. Which of the following language does the computer understand?
a) Computer understands only C Language
b) Computer understands only Assembly Language
c) Computer understands only Binary Language
d) Computer understands only BASIC

Answer: c
Explanation: The Computer understands only binary language which is written in the form of 0s & 1s. A computer can understand assembly language but an assembler is required which convert the assembly language to binary language. Similarly, for understanding high level languages, compilers/interpreters are required.

6. Which of the following computer language is written in binary codes only?
a) pascal
b) machine language
c) C
d) C#

Answer: b
Explanation: Machine Language is written in binary codes only. It can be easily understood by the computer and is very difficult for us to understand. A machine language, unlike other languages, requires no translators or interpreters.

7. Which of the following is the brain of the computer?
a) Central Processing Unit
b) Memory
c) Arithmetic and Logic unit
d) Control unit

Answer: a
Explanation: The CPU is referred to as the brain of a computer.
It consists of a control unit and an arithmetic and logic unit. It is responsible for performing all the processes and operations.

8. Which of the following is not a characteristic of a computer?
a) Versatility
b) Accuracy
c) Diligence
d) I.Q.

Answer: d
Explanation: The Computer system has no I.Q. of its own. It does only what it is programmed to do. It cannot take decisions of its own.
A computer is diligent because it can work continuously for hours without getting any errors or without getting grumbled.
The accuracy of a computer is consistently high and its level of accuracy depends on its design. A computer can perform any task if, it can be broken down into a series of logical steps. Therefore, a computer is versatile.

9. Which of the following is the smallest unit of data in a computer?
a) Bit
b) KB
c) Nibble
d) Byte

Answer: a
Explanation: A bit is defined as the smallest unit of data in a computer system. It is used as a short form of Binary Digit. A bit can have only two values 0 or 1. A nibble comprises 4 bits, a byte is a collection of 8 bits whereas KB (Kilobyte) is equal to 1024 bytes.

10. Which of the following unit is responsible for converting the data received from the user into a computer understandable format?
a) Output Unit
b) Input Unit
c) Memory Unit
d) Arithmetic & Logic Unit

Answer: b
Explanation: The Input Unit converts the data, which the user enters into a language that the computer understands, i.e. it converts the data into binary format. The Output Unit is responsible for giving the results in a user-understandable format. The Storage Unit is responsible for storing the data after immediate results of processing whereas; the ALU is responsible for various arithmetic and bitwise operations.