Introduction to Java & BlueJ

ICSE Class 8 Computer Studies · Class - 8: ICSE Kips Logix Computer Book Solutions with BlueJ · 33 solved questions

Exercise
Marks
1Fill in the blanks

The Java programming language is an Object Oriented Programming language.

Solution not available in the source paper.

2Fill in the blanks

Encapsulation is the technique of binding both data and functions together.

Solution not available in the source paper.

3Fill in the blanks

A Class is a blueprint that defines data and functions common to all objects of a certain kind.

Solution not available in the source paper.

4Fill in the blanks

The smallest meaningful element of a Java program is called a Token.

Solution not available in the source paper.

5Fill in the blanks

Initialization is a process of assigning some initial value to a variable.

Solution not available in the source paper.

1State True or False

Polymorphism allows a function to behave differently for different objects.
True

Solution not available in the source paper.

2State True or False

Constants mean the fixed values that do not change during the execution of a program.
True

Solution not available in the source paper.

3State True or False

The main() function indicates that the execution of the Java program will begin from this point.
True

Solution not available in the source paper.

4State True or False

Every Java statement must end with a colon.
False

Solution not available in the source paper.

5State True or False

Inheritance is a feature using which an object in one class acquires the properties of another class.
True

Solution not available in the source paper.

6State True or False

While comparing two variables, their data types should not be the same.
False

Solution not available in the source paper.

1Application Based Questions

Ritika has written a program in Java. After the successful compilation of her program, which option should she select to run it?

Show SolutionHide Solution↓

To run her program, Ritika needs to right-click on the class icon and select void main(String[] args) option from the pop-up menu.

2Application Based Questions

Kareena is writing a program in Java to calculate the average of three subjects. Which operators will she use for the same?

Show SolutionHide Solution↓

Kareena will use the addition operator (+) to first calculate the total marks obtained in all three subjects. After that, she will use the division operator (/) to divide the total marks by 3 to get the average.

11 Mark · Multiple Choice Questions

A .......... is a named location in the memory, which stores data temporarily.

Show SolutionHide Solution↓
  • Variable ✓
  • 21 Mark · Multiple Choice Questions

    What does OOP mean?

    Show SolutionHide Solution↓
  • Object Oriented Programming ✓
  • 31 Mark · Multiple Choice Questions

    Which among the following feature is used to manage the complexity of the system?

    Show SolutionHide Solution↓
  • Abstraction ✓
  • 41 Mark · Multiple Choice Questions

    A Java program is compiled into an intermediate language called ..........

    Show SolutionHide Solution↓
  • Bytecode ✓
  • 51 Mark · Multiple Choice Questions

    The .......... works on a single variable or constant.

    Show SolutionHide Solution↓
  • Unary Operator ✓
  • 61 Mark · Multiple Choice Questions

    Which symbol is used to combine two or more items in a single line?

    Show SolutionHide Solution↓
  • + ✓
  • 1Answer the following

    Define objects. Give a real life example to explain objects along with their attributes and behaviour.

    Show SolutionHide Solution↓

    An object represents data (attributes) and its related methods (behaviour) as a single unit. Take the example of a car. When we describe a car as an object, there are a number of physical factors which contribute to define its state such as its brand name, colour, speed, size, number of seats, etc. In addition, the car has several functional definitions. It transports people to different locations by controlling its speed and direction, an accelerator to increase or decrease its speed and brakes to stop it. Thus we can say that car is an object that combines its attributes and behaviour as a single unit.

    2Answer the following

    What is class?

    Show SolutionHide Solution↓

    A class is a blueprint to create objects. It defines data and functions common to all objects of a certain kind.

    3Answer the following

    What do you understand by the term Polymorphism?

    Show SolutionHide Solution↓

    The word Polymorphism means "many forms". Polymorphism helps the programmer to use the same function name for more than one purpose.

    4Answer the following

    What are operators? Why do we need them?

    Show SolutionHide Solution↓

    Operators are special symbols that are used to perform calculations. We need operators to form expressions by applying them to the variables and constants.

    5Answer the following

    What do you understand by the term Keyword?

    Show SolutionHide Solution↓

    Keywords are reserved words that have a special meaning for the Java compiler. Java compiler reserves these words for its own use so Keywords cannot be used as identifiers. For example, void, public, class, int, etc.

    6Answer the following

    What are variables? How are they different from Constants?

    Show SolutionHide Solution↓

    A variable is a named location in the memory which stores data temporarily. A variable has a unique name, a type and a size that is used to identify it in a program.

    Difference between variables and constants is that the value of variables can change during the execution of the program whereas value of constants are fixed and does not change during program execution.

    1Lab Session

    Write a program to print, "Welcome to the World of Computers".

    public class KboatWelcome
    {
        public static void main(String args[]) {
            System.out.println("Welcome to the World of Computers");
        }
    }
    BlueJ output of KboatWelcome.java

    Solution not available in the source paper.

    2Lab Session

    Write a program to print your Name, Class, Roll_No, Marks and Age. Name this file, `MyProfile'.

    public class MyProfile
    {
        public static void main(String args[]) {
            System.out.println("Name: Sneha Nayak");
            System.out.println("Class: 8C");
            System.out.println("Roll No: 24");
            System.out.println("Marks: 87");
            System.out.println("Age: 15");
        }
    }
    BlueJ output of MyProfile.java

    Solution not available in the source paper.

    3Lab Session

    Write a program to print your School name four times in separate lines.

    public class KboatSchoolName
    {
        public static void main(String args[]) {
            System.out.println("St. Francis' College");
            System.out.println("St. Francis' College");
            System.out.println("St. Francis' College");
            System.out.println("St. Francis' College");
        }
    }
    BlueJ output of KboatSchoolName.java

    Solution not available in the source paper.

    4Lab Session

    Write a program to find the sum and average of three numbers.

    public class KboatSumAvg
    {
        public static void computeSumAvg(int a, int b, int c) {
            System.out.println("The three numbers are " 
              + a + ", " + b + ", " + c );
            int sum = a + b + c;
            double avg = sum / 3.0;
            System.out.println("Sum = " + sum);
            System.out.println("Average = " + avg);
        }
    }
    BlueJ output of KboatSumAvg.java

    Solution not available in the source paper.

    5Lab Session

    Write a program to interchange the value of two numbers without using the third variable.

    public class KboatSwap
    {
        public static void swapNumbers(int a, int b) {
            System.out.println("The numbers are:");
            System.out.println("a=" + a + " b=" + b);
            a = a + b;
            b = a - b;
            a = a - b;
            System.out.println("The numbers after interchange:");
            System.out.println("a=" + a + " b=" + b);
        }
    }
    BlueJ output of KboatSwap.java

    Solution not available in the source paper.

    6Lab Session

    Write a program to calculate the compound interest.

    public class KboatInterest
    {
        public static void computeInterest(double p, double r, int t) {
            double amt = p * Math.pow(1 + (r / 100 ), t);
            double interest = amt - p;
            System.out.println("Compound Interest = " + interest);
        }
    }
    BlueJ output of KboatInterest.java

    Solution not available in the source paper.

    7Lab Session

    Write a program to calculate the tax for a taxable income of Rs. 4,10,000, if the tax rate is fixed at 3.2%.

    public class KboatTax
    {
        public static void main(String args[]) {
            int income = 410000;
            double rate = 3.2;
            double tax = income * rate / 100;
            System.out.println("Tax = " + tax);
        }
    }
    BlueJ output of KboatTax.java

    Solution not available in the source paper.

    8Lab Session

    Create a program that will generate a bill at McDonald's for four vegetable burgers (@ Rs 45 per vegetable Burger) and three vegetable McPuffs (@ Rs 25 per vegetable McPuff). There is a special Independence Day discount of Rs 50 on the final bill amount.

    public class KboatMcDBill
    {
        public static void main(String args[]) {
            int vegBurgerCost = 4 * 45;
            int vegMcPuffCost = 3 * 25;
            int total = vegBurgerCost + vegMcPuffCost;
            int amt = total - 50;
            System.out.println("4 Vegetable Burgers @ 45 = " + vegBurgerCost);
            System.out.println("3 Vegetable McPuffs @ 25 = " + vegMcPuffCost);
            System.out.println("Total = " + total);
            System.out.println("Discount = 50");
            System.out.println("Final Bill = " + amt);
        }
    }
    BlueJ output of KboatMcDBill.java

    Solution not available in the source paper.

    Press ↓ to reveal a solution and move to the next question. Back to Class - 8: ICSE Kips Logix Computer Book Solutions with BlueJ.