Home » Java Objective » Java Basic code snippet based Question

Java Basic code snippet based Question

Last updated:

Support this post with a reaction:

4,021 views

Answered 0 / 74 · Correct 0

  1. Q1 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            System.out.println("Hello, World!");
        }
    }
  2. Q2 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 5;
            int y = 10;
            System.out.println(x + y);
        }
    }
  3. Q3 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 5;
            System.out.println(x++);
            System.out.println(x);
        }
    }
  4. Q4 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 5;
            System.out.println(++x);
        }
    }
  5. Q5 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 5;
            System.out.println(x--);
            System.out.println(x);
        }
    }
  6. Q6 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 5;
            System.out.println(--x);
        }
    }
  7. Q7 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 5;
            x += 10;
            System.out.println(x);
        }
    }
  8. Q8 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 10;
            x -= 5;
            System.out.println(x);
        }
    }
  9. Q9 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 5;
            x *= 2;
            System.out.println(x);
        }
    }
  10. Q10 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 10;
            x /= 2;
            System.out.println(x);
        }
    }
  11. Q11 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 10;
            x %= 3;
            System.out.println(x);
        }
    }
  12. Q12 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 10;
            System.out.println(x > 5);
        }
    }
  13. Q13 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 10;
            System.out.println(x < 5);
        }
    }
  14. Q14 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 10;
            System.out.println(x == 10);
        }
    }
  15. Q15 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 10;
            System.out.println(x != 10);
        }
    }
  16. Q16 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 10;
            System.out.println(x >= 10);
        }
    }
  17. Q17 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 10;
            System.out.println(x <= 5);
        }
    }
  18. Q18 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 5;
            int y = 10;
            System.out.println(x > y);
        }
    }
  19. Q19 Easy

    What will be the output of the following code?

    public class Test {
        public static void main(String[] args) {
            int x = 5;
            int y = 10;
            System.out.println(x < y);
        }
    }