import java.util.*;
import java.lang.*;
import java.io.*;

        // The main method must be in a class named "Main".
        class Main {
        public static void main(String[] args) {
        //    System.out.println("Hello world!");

            // Q1. Print in a single line the total elapsed cooking time.
            
            // Scanner scn = new Scanner(System.in);
            // int N = scn.nextInt(); // number of layers
            // int M = scn.nextInt(); // number of time already spent baking in oven

            // int TTFCEL = N * 2;
            // int ECT = TTFCEL + M;
            // System.out.println(ECT);
            

        // ----------------------------------------------

        // Q2. Which of the following is an incorrect way of declaring variables in Java?
            //a) int a = 10; 
            //b)  int a = 20, int b = 30; - incorrect - semi colon missing (should be declared alternatively as (int a = 20; b = 30;)
            //c) double a = 10;
            // d) boolean a = true;


        // ----------------------------------------------

    
        // Q3. What will be the output of the following code ?
            // float a = 5/2;
            // System.out.println(a);

            // 2.5
            // 2.0   - Correct answer
            // 2.50
            // None of the above
                
            // Example:
            // float a = 5/2;
            // float b = 5.0f/2.0f;
            // System.out.println(a);
            // System.out.println(b);

        // ----------------------------------------------

        // Q4.  Which of the following is not a valid Data Type in JAVA ?
            // long
            // bool - Not a Valid Data Type.
            // double
            // float

        // ----------------------------------------------

        // Q5.  What is the correct output ?
            // float a = 35f / 0;
            // System.out.println(a);


        // ----------------------------------------------

        // Q6.  The allowed values for the boolean data type are?
            // True
            // False
            // true  - Correct Answer.
            // null

// ----------------------------------------------
            
        // Additional Problems 7/7
        // Q1. Given two numbers A and B. Multiply them and print the product.

            // Scanner scn = new Scanner(System.in);
            // int A = scn.nextInt();
            // int B = scn.nextInt();

            // System.out.println(A*B);
            
        // ----------------------------------------------

            // Q2. Given total bills amount and amount of a single bill. Print number of bills.

            // Scanner scn = new Scanner(System.in);

            // double TBA = scn.nextDouble();
            // int A = (int)TBA;
            // int SBA = scn.nextInt();

            // System.out.println("The Total Number of Bills are " + A/SBA);

        // ----------------------------------------------

            // Q3. What is the result of a Narrowing Type Conversion in JAVA?
            // Loss of Data   - Correct Answer
            // Gain of Data
            // No change
            // None of the above

        // ----------------------------------------------

            // Q4. What is the result of a Widening Type Conversion in JAVA?
            // Loss of Data
            // Gain of Data
            // No change      - Correct Answer
            // None of the above

        // ----------------------------------------------

            // Q5. Which of the following automatic type conversion will be possible?
            // float to int
            // int to long
            // long to int
            // double to int

        // ----------------------------------------------
            // Q6. What is the output of the below Java code snippet?

            // float a = 8.2/2;
            // System.out.println(a);

            // 4.1
            // 8.1
            // 4
            // Compilation error    -  Correct Answer

        // ----------------------------------------------
            // Q7. Which of the following is incorrect ?
            
            // int n = scn.nextInt();
            // float n = scn.nextInt();
            // double n = scn.nextFloat();
            // float n = scn.nextDouble();   -  Incorrect Answer.

    }
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: