KnowledgeBoat Logo

Chapter 4 - Unit 3

History and Development of Java

Class 11 - APC Understanding ISC Computer Science with BlueJ



Indicate whether the following statements are true or false

Question 1

Source code is also called an object program.
False

Question 2

JVM converts byte code to machine code.
True

Question 3

Keywords are also referred to as reserved words.
True

Question 4

Multi line comments are same as documentation comments.
False

Question 5

Java is a menu based approach.
False

Question 6

There is no difference between print() and println() statement.
False

Question 7

Java language can use applications as well as applets.
True

Question 8

Java language is developed by Sun Micro-systems.
True

Question 9

Java language uses compiler but not an interpreter.
False

Question 10

Byte code and machine code are synonyms.
False

Fill in the blanks with the appropriate word/words

Question 1

A program of Java that can be developed and executed by the users, is known as Java application.

Question 2

The inventor of Java is James Gosling.

Question 3

Java Virtual Machine (JVM) is a Java interpreter.

Question 4

Keywords can also be called Java reserved word.

Question 5

BlueJ is a window based platform to execute Java programs.

Question 6

We can write comments in a Java language by three ways.

Question 7

Debugging is the term used to correct the error in a program.

Question 8

JDK 1.5 is a DOS based platform for Java programs.

Write short answers

Question 1

What is Java? What was it called initially?

Answer

Java is an Object Oriented programming language developed in 1991 by James Gosling at Sun Microsystems. It was initially called 'Oak'.

Question 2

What are the features of Java?

Answer

The features of Java are:

  1. It is an Object Oriented Programming Language.
  2. It is platform independent. It provides us Write Once, Run Anywhere (WORA) feature.
  3. It uses a compiler as well as an interpreter.
  4. It is case sensitive.
  5. It is a multithreaded language.

Question 3

Name a Java package, which is imported by default.

Answer

java.lang

Question 4

Explain briefly about the development of Java language.

Answer

In 1991, at Sun Microsystems, Green team led by James Gosling started working on a new technology for consumer electronic devices. Over the next 18 months, in 1992 the team created a new programming language which they called “Oak”. By 1994 the team refocussed their efforts towards internet programming with Oak as it didn't find much traction in consumer electronics space. Oak was renamed to Java and on 23rd of May 1995, Sun microsystems made its first public release.

Question 5

What are the different ways to give comments in Java Programming?

Answer

There are three ways to write comments in Java:

  1. Single Line comment.
  2. Multi line comment.
  3. Documentation comment.

Question 6

Explain the significance of the following Java library packages.

(a) java.lang

Answer

It provides classes that are fundamental to the design of the Java programming language. Some of the important classes it contains are Object, which is the root of the class hierarchy, Class, instances of which represent classes at run time, Wrapper classes and Math class, which provides commonly used mathematical functions such as sine, cosine, square root, etc.

(b) java.io

Answer

It contains the classes that handle fundamental input and output operations in Java.

(c) java.math

Answer

java.math package provides classes for performing arbitrary-precision integer arithmetic (BigInteger) and arbitrary-precision decimal arithmetic (BigDecimal). Refer to the official documentation for more details.

Clarification: Mathematical Library Functions like min(), max(), abs(), avg(), floor(), ceil(), round(), sqrt(), pow(), etc. are present in Math class of java.lang package. java.lang.Math class should not be confused with java.math package.

Question 7

Give an example of each with reference to Java programming:

(a) Single Line comment

Answer

// This is my first program.

(b) Multi Line comment

Answer

/* This is my first program.
It calculates the sum of two numbers.*/

Question 8

Define the terms:

(a) Source code

Answer

A set of statements written in a High-Level programming language like Java, C++, Python, etc. is called as Source Code.

(b) Machine code

Answer

Machine code is a low-level programming language. Instructions in machine code are written as a sequence of 0s and 1s. It is directly understood and executed by the processor.

(c) Byte code

Answer

Java compiler converts Java source code into an intermediate binary code called Bytecode. Bytecode can't be executed directly on the processor. It needs to be converted into Machine Code first.

Question 9

Distinguish between:

(a) Compiler and Interpreter

Answer

CompilerInterpreter
It converts the whole source program into object program at once.It converts the source program into object program one line at a time.
It displays the errors for the whole program together after compilation.It displays the errors of one line at a time and after debugging the control goes to the next line.

(b) Java (JDK 1.5) and BlueJ

Answer

JDK 1.5BlueJ
JDK or Java Development Kit is the set of tools required to compile and run Java programsBlueJ is an IDE or Integrated Development Environment for developing Java programs.
JDK includes tools like Compiler, Interpreter, Java libraries, etc.BlueJ provides tools like Code Editor, Debugger, Syntax Highlighting, etc.
JDK is essential for developing Java programs.IDE isn't essential for developing Java programs but it makes the process easier and efficient.

Question 10

What is BlueJ? What are the features of BlueJ?

Answer

BlueJ is an integrated development environment for Java. It was created for teaching Object Oriented programming to computer science students. Features of BlueJ are:

  1. Simple beginner friendly graphical user interface.
  2. It allows creating objects of the class dynamically, invoking their methods and also supplying data to the method arguments if present.
  3. It supports syntax highlighting. (Syntax highlighting means showing the different tokens of the program like keywords, variables, separators, etc. in different colours so that they show up more clearly.)
  4. It facilitates easier debugging as lines causing compilation errors are marked clearly and the error is displayed at the bottom of the window.
  5. It provides a code editor, compiler and debugger integrated into a single tool.

Question 11

Write down the syntax of output statement in Java programming with an example

Answer

We commonly use two output statements in Java. There syntax are:

  1. System.out.println(<output value>); — This statement prints data on the console. The data to be printed is passed to the println method as a String. After printing the string, it places the cursor at the start of the next line. So the next printing happens at the start of the next line.
  2. System.out.print(<output value>); — This statement also prints data on the console. The data to be printed is passed to the print method as a String. After printing the string, the cursor remains on the same line at the end of the printed string. So the next printing starts in the same line just after the end of the previous printed string.

As an example, the below statements will generate the following output:

System.out.println("JVM stands for");
System.out.print("Java ");
System.out.print("Virtual ");
System.out.print("Machine");
Output
JVM stands for
Java Virtual Machine

Question 12

What do you understand by Java reserved words? Name at least five Java reserved words which are commonly used in Java programming.

Answer

In Java, a reserved word is a word that has a predefined meaning in the language. Due to this, reserved words can’t be used as names for variables, methods, classes or any other identifier. Reserved words are also known as keywords. Five commonly used Java reserved words are:

  1. public
  2. class
  3. int
  4. double
  5. char

Question 13

Write down all the steps to compile and execute a Java program.

Answer

  1. Right click on the class icon in the BlueJ main window.
  2. Select the compile option from the menu that appears.
  3. Again right click on the class icon in the BlueJ main window and select the option void main(String[] args).
  4. Click OK on the method call window that appears on the screen.
  5. The desired output of the program will be shown on the screen.

Question 14

'Java interpreter is also called Java Virtual Machine'. Justify the statement.

Answer

Java Virtual Machine takes Bytecode as input and converts it into Machine Code one line at a time. This Bytecode can be generated by compiling source code written in any JVM language like Scala, Kotlin, etc not just Java. Hence, Java interpreter is called Java Virtual Machine.

Question 15

A Java program uses Compiler as well as Interpreter. Explain.

Answer

Java compiler compiles Java source code to Bytecode. Bytecode cannot run on the processor directly as processor only understands Machine Code. Java Virtual Machine (JVM) takes this Bytecode as input and converts it into Machine Code line by line. So, JVM acts as an interpreter for converting Bytecode to Machine Code. In this way, a Java program uses both a Compiler as well as an Interpreter to get executed on the processor.

Question 16

Distinguish between System.out.print() and System.out.println() with an example.

Answer

System.out.println()System.out.print()
It prints data to the console and places the cursor in the next line.It prints data to the console but the cursor remains at the end of the data in the same line.
Next printing takes place from next line.Next printing takes place from the same line.

Question 17

How can you modify a Java program on BlueJ platform?

Answer

To modify a Java program on BlueJ platform we will double click the class icon to open the source code of the class. Now we will make the required modification to this Java program.

PrevNext