Blog Detail

September 23, 2023

Java Data Types Exercises – Part 2

  • Choose the proper data type.

                    class Main {
      public static void main(String[] args) {
        "" result = Math.max(30, 33);
        System.out.println(result);
      }
    }
  • Choose the proper data type.

                    class Main {
      public static void main(String[] args) {
        "" result = Math.max(30.2, 33.1);
        System.out.println(result);
      }
    }
  • Choose the proper data type.

                    class Main {
      public static void main(String[] args) {
        "" result = "FashionistaQueen".length();
        System.out.println(result);
      }
    }
  • Choose the proper data type.

                    class Main {
      public static void main(String[] args) {
        double marketShare = 12.03325;
        "" roundedMarketShare = Math.round(marketShare);
        
        System.out.println(roundedMarketShare);
      }
    }
  • Choose the proper data type.

                    class Main {
      public static void main(String[] args) {
        String sentence = "The quick brown fox jumps over the lazy dog";
        String keyword = "fox";
    
        "" result = sentence.contains(keyword);
    
        System.out.println(result);
      }
    }
  • Choose the proper data type.

                    class Main {
      public static void main(String[] args) {
        String userName = "AAABoy";
        "" result = userName.toUpperCase();
    
        System.out.println(result);
      }
    }
  • Java Exercises for Data Types

    • If you’ve faced difficulties with these exercises, take a look at Data Types Module on my Java course.


    You can also share ‘Java Data Types’ Exercises on your:
    X (Twitter)TelegramLinkedinFacebook – or on your favorite platform…




    Happy Coding!
    Behnam Khani