Quiz #3: Java Programming Basics

Test your knowledge with some basic knowledge of Java
  1. What is the correct statement to print "Hello World" (without double quotes)?

  2. System.out.println("Hello World")
    System.out("Hello World");
    System.out.println("Hello World");
    System.out.println('Hello World');
  3. What is the result of the following calculation?

  4. 1 public class Main {
    2 public static void main(String[] args) {
    3 // Write your code here
    4 int a = 3;
    5 int b = 4;
    6 int c = 5;
    7 System.out.println(a + b * c + b);
    8 }
    9 }
    63
    27
    39
  5. What is the result of the following calculation?

  6. public class Ex { 
    public static void main(String[] args) {
    System.out.println(5 + 15 / 3 * 2 - 8 % 3);
    }
    }
    Missing Word
  7. Is string concatenation using '+' allowed in Java?

  8. Yes
    No
  9. What is the result of print statement in this Java program (+=)?

  10. public class AssShortcutExample {
       public static void main(String args[]) {
          int num1 = 10;
          int num2 = 20;
    
          num2 += num1;
          System.out.println("= Output: "+num2);
    }
    }
    Missing Word
  11. What is the result of print statement in this Java program (-=)?

  12. public class AssShortcutExample {
       public static void main(String args[]) {
          int num1 = 10;
          int num2 = 20;
    
          num2 -= num1;
          System.out.println("= Result: "+num2);
    }
    }
    Missing Word
  13. What is the difference between float and double data types in Java?

  14. float is a decimal number and double is not
    float can be used inside classes but double cannot
    float provides less decimal points than double
    float cannot be passed as a variable to method but double could be
  15. What is the difference between int and long in Java?

  16. int is a data type to represent number, but long is used for string
    long is data type which is no longer used in java where it was replaced by int
    int is 32-bit width where long is 64-bit width
    The decimal point of long is 64-bit where int decimal point is 32-bit


Show Answer without submitting