Quiz Discussion

What will be the output of the following Java program?

    public class array_output 
    {
        public static void main(String args[]) 
        {
       	    int array_variable [] = new int[10];
	    for (int i = 0; i < 10; ++i) {
                array_variable[i] = i/2;
                array_variable[i]++;
                System.out.print(array_variable[i] + " ");
                i++;
            }
 
        } 
    }

 

Course Name: Java

  • 1]

    0 2 4 6 8

  • 2]

    1 2 3 4 5

  • 3]

     0 1 2 3 4 5 6 7 8 9

  • 4]

    1 2 3 4 5 6 7 8 9 10

Solution
No Solution Present Yet

Top 5 Similar Quiz - Based On AI&ML

Quiz Recommendation System API Link - https://fresherbell-quiz-api.herokuapp.com/fresherbell_quiz_api

# Quiz
1
Discuss

Which of these can not be used for a variable name in Java?

  • 1]

    identifier

  • 2]

    keyword

  • 3]

    identifier & keyword

  • 4]

    none of the mentioned

Solution
2
Discuss

Which of these is long data type literal?

  • 1]

     0x99fffL

  • 2]

    ABCDEFG

  • 3]

    0x99fffa

  • 4]

    99671246

Solution
3
Discuss

What will be the output of the following Java program?

    public class dynamic_initialization 
    {
        public static void main(String args[]) 
        {
            double a, b;
            a = 3.0;
            b = 4.0;
	    double c = Math.sqrt(a * a + b * b);
	    System.out.println(c);
        } 
    }

 

  • 1]

    5.0

  • 2]

    25.0

  • 3]

    7.0

  • 4]

    Compilation Error

Solution
4
Discuss

What will be the output of the following Java program?

    public class variable_scope 
    {
        public static void main(String args[]) 
        {
            int x;
            x = 5;
            {
	        int y = 6;
	        System.out.print(x + " " + y);
            }
            System.out.println(x + " " + y);
        } 
    }

 

  • 1]

    5 6 5 6

  • 2]

    5 6 5

  • 3]

    Runtime error

  • 4]

    Compilation error

Solution
5
Discuss

Which of these can be returned by the operator &?

  • 1]

    Integer

  • 2]

    Boolean

  • 3]

    Character

  • 4]

    Integer or Boolean

Solution
6
Discuss

What will be the output of the following Java program?

    public class evaluate 
    {
        public static void main(String args[]) 
        {
            int a[] = {1,2,3,4,5};
	    int d[] = a;
	    int sum = 0;
	    for (int j = 0; j < 3; ++j)
                sum += (a[j] * d[j + 1]) + (a[j + 1] * d[j]);
	    System.out.println(sum);
        } 
    }

 

  • 1]

    38

  • 2]

    39

  • 3]

    40

  • 4]

    41

Solution
# Quiz