KnowledgeBoat Logo

Chapter 1 - Unit 2

Introduction to Java

Class 9 - APC Understanding Computer Applications with BlueJ

Write True or False

Question 1

Java application is a Java program which is developed by users.

Question 2

James Gosling developed Java programming language.

Question 3

Machine codes are expressed using alphanumeric characters.

Question 4

Byte code is the program in binary form.

Question 5

JVM is Java Visual Management.

Fill in the blanks with appropriate words

Question 1

Java is a case sensitive language.

Question 2

In Java, the package used to find power raised to any base is java.lang.

Clarification: Math class inside java.lang package contains Math.pow that is used to find power raised to any base. The official documentation is provided here.
It should not be confused with java.math package which contains BigDecimal, BigInteger and MathContext classes.

Question 3

The words which are preserved with the system are called keywords/reserved words, that can not be used as variable names in Java programming.

Question 4

A single line comment is represented by the symbol // in Java programming.

Question 5

BlueJ is a window based platform to operate Java program.

Answer the following questions

Question 1

Who developed Java? What was it initially called?

James Gosling developed Java programming language. It was initially called Oak.

Question 2

Give a brief historical development of Java.

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 3

Mention at least four features of Java.

Four 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.

Question 4

Define the following:

(a) A compiler

A compiler is a program that translates a source program written in some high-level programming language into a target program in another low-level programming language without changing the meaning of the program. The compiler processes the complete source program at once and if there are compilation errors, they are all reported together at once.

(b) An interpreter

An interpreter is a program that reads a source program line by line, converts each line into its equivalent machine code and executes it. As it reads the program line by line so the errors are reported one by one.

(c) Byte code

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 5

What is Java Virtual Machine (JVM)?

Java Virtual Machine (JVM) is a software that takes Bytecode as input, converts it into Machine code of the specific platform it is running on and executes it. JVM is platform specific, each platform has its own JVM.

Question 6

Name three packages of Java Class Library.

Three packages of Java Class Library are:

  1. java.lang
  3. java.util

Question 7

What are Java reserved words? Name any five.

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 8

Distinguish between:

(a) Source code and Object code

Source codeObject code
It is a set of statements in a High-Level programming language.It is a set of statements in Machine Language.
It is understood by human/programmer.It is understood by the processor.

(b) Compiler and Interpreter

It translates the whole source program into target program at once.It translates the source program into target program one line at a time.
All the errors found during compilation are displayed together at once.Errors are displayed line by line as each line is translated and executed.

(c) JDK 1.3 and BlueJ

JDK 1.3BlueJ
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 9

A compiler is specific to a language. Give your comments.

A compiler translates a source program written in some high-level programming language into a target program in another low-level programming language. As low-level programming languages are platform specific hence a compiler is specific to a language.

Question 10

What is the basic format of a Java Program? Explain with an example.

The basic format of a Java program with example is explained here.

Question 11

What is BlueJ?

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

Question 12

Mention five features of BlueJ.

Five 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 13

Name a package that is invoked by default.


Question 14

What are the points to be taken care while naming a class in a Java program?

A class name should be a valid Java identifier i.e. it should follow the below three rules:

  1. Name of the class should be a sequence of alphabets, digits, underscore and dollar sign characters only.
  2. It should not start with a digit.
  3. It should not be a keyword or a boolean or null literal.

Question 15

Java is a case sensitive. Explain.

Java is case sensitive means that it distinguishes between upper case and lower case characters. Consider the below code snippet:

int studentMarks;
StudentMarks = 85;

This will give a compilation error as Java will treat studentMarks and StudentMarks as two different variables because the case of the characters is not same in both.

Question 16

The main function in a Java program is declared as:
     public static void main (String args[])
What is the significance of the words public, static and void?

public — The public keyword is an access specifier. It controls the visibility of class members. We can access public class members outside the class where we declare them. We need to make the main method public because it will be called by code outside of its class when the program is started.

static — When we declare a method inside a class as static, we can call it without creating the object of that class. We need to make the main method static because Java Virtual Machine (JVM) will call it to start the program even before any objects of the class are created.

void — The void keyword tells the compiler that the main method will not return any value.

Question 17

What does the term 'Compilation' mean?

The process of converting a source program written in some high-level programming language into a target program in another low-level programming language without changing the meaning of the program is called Compilation.

Question 18

Java program uses compiler as well as interpreter. Explain.

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 19

Design a program in Java to display the following information on the output screen:
Roll No.:

class StudentInfo {
    public static void main(String args[]) {
        System.out.println("Name: Akshay Anand");
        System.out.println("Class: 10");
        System.out.println("Roll No.: 5");
        System.out.println("Subject: Computer Applications");
        System.out.println("School: KnowledgeBoat");

Question 20

You want to display your bio-data on the output screen. Write a program in Java to perform the task in the given format:
Father's Name:
Date of birth:
Blood Group:
Aadhar Card No.:

class BioData {
    public static void main(String args[]) {
        System.out.println("Name: Shweta Nayak");
        System.out.println("Father's Name: Arvind Nayak");
        System.out.println("Date of birth: 12/12/2005");
        System.out.println("Blood Group: O+");
        System.out.println("Aadhar Card No.: 4321 8756 9978");
        System.out.println("State: Karnataka");

Video Explanations