Java Questions & Answers – Character and Boolean Data Types

1
Created on By admin

Java Questions & Answers – Character and Boolean Data Types

1 / 10

1. What is the numerical range of a char data type in Java?

 

2 / 10

2. Which of these coding types is used for data type characters in Java?

 

3 / 10

3. Which of these values can a boolean variable contain?

 

4 / 10

4. Which of these occupy first 0 to 127 in Unicode character set used for characters in Java?

 

5 / 10

5. Which one is a valid declaration of a boolean?

 

6 / 10

6. What will be the output of the following Java program?

  1.     class array_output {
  2.         public static void main(String args[])
  3.         {
  4.             char array_variable [] = new char[10];
  5. 	    for (int i = 0; i < 10; ++i) {
  6.                 array_variable[i] = 'i';
  7.                 System.out.print(array_variable[i] + "" );
  8.                 i++;
  9.             }
  10.         }
  11.     }

 

 

7 / 10

7. What will be the output of the following Java program?

  1.     class mainclass {
  2.         public static void main(String args[])
  3.         {
  4.             char a = 'A';
  5.             a++;
  6. 	    System.out.print((int)a);
  7.         }
  8.     }

 

 

 

8 / 10

8. What will be the output of the following Java program?

  1.     class mainclass {
  2.         public static void main(String args[])
  3.         {
  4.             boolean var1 = true;
  5. 	    boolean var2 = false;
  6. 	    if (var1)
  7. 	        System.out.println(var1);
  8. 	    else
  9. 	        System.out.println(var2);
  10.        }
  11.     }

     

 

 

9 / 10

9. What will be the output of the following Java code?

  1.     class booloperators {
  2.         public static void main(String args[])
  3.         {
  4.             boolean var1 = true;
  5. 	    boolean var2 = false;
  6. 	    System.out.println((var1 & var2));
  7.         }
  8.     }

     

 

 

10 / 10

10. What will be the output of the following Java code?

  1.     class asciicodes {
  2.         public static void main(String args[])
  3.         {
  4.             char var1 = 'A';
  5. 	    char var2 = 'a';
  6. 	    System.out.println((int)var1 + " " + (int)var2);
  7.         }
  8.     }

 

 

Your score is

The average score is 20%

0%

Leave a Reply

Your email address will not be published. Required fields are marked *