Java Brush Questions Interview Series Exercises (8)


Programmer 👉Click to start free questioning, follow the blogger to the top 💪
 

 

 


foreword

The blogger accidentally brushed the question and found this very good websiteNiuke.com, went in and brushed it, and foundVery broad coverage, not onlyBig factory interview questions,and alsoXiaobai's introductory algorithm questions, which is very friendly to people who have just come into contact with computer languages, so the blogger decided to open a column, which is recorded in detail inExplanation of the idea of ​​brushing questions on Niuke.com, let's follow the bloggers into the door of the algorithm!
👉Click to start free questioning and follow the blogger to the top 💪


insert image description here


insert image description here


insert image description here


Java Question Practice


⭕ Topic 1: Character to ASCII code


insert image description here


🌟 Code demo

import  java . useless _ Scanners ;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        char a = in.next().charAt(0);
        int num = a;
        System.out.println(num);
    } 
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

💯Analysis of ideas

       The idea of ​​​​this topic is: "Enter the character type, then convert it to int type, and implicit conversion from small to large"
  • 1

⭕ Topic 2: Implement rounding


insert image description here


🌟 Code demo

import  java . useless _ Scanners ;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        float f=sc.nextFloat();
        System.out.print(Math.round(f));
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

💯Analysis of ideas

       The idea of ​​​​this topic is: "Enter a floating point number and call the round method in the Math class"
  • 1

⭕Question 3: Score input and output


insert image description here


🌟 Code demo

import  java . useless _ Scanners ;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int s1 = scanner.nextInt();
        int s2 = scanner.nextInt();
        int s3 = scanner.nextInt();
        System.out.println("score1=" + s1 + "," + "score2=" + s2 + "," + "score3=" + s3);
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

💯Analysis of ideas

       The idea of ​​this topic is: "It's too easy"
  • 1

⭕ Topic 4: Input and output of basic information of students


insert image description here


🌟 Code demo

import  java . useless _ Scanners ;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String s=sc.nextLine();
        String[] arr=s.split(";");
        String[] scores=arr[1].split(",");
        Double[] scores1=new Double[3];
        for(int i=0;i<scores.length;i++)
            scores1[i]=Double.parseDouble(scores[i]);
        System.out.printf("The each subject score of No. %s is %.2f, %.2f, %.2f.",arr[0],scores1[0],scores1[1],scores1[2]);
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

💯Analysis of ideas

       The idea of ​​this topic is: "Just follow the topic"
  • 1

⭕ Topic 5: Input and output of date of birth


insert image description here


🌟 Code demo

import  java . useless _ Scanners ;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String n=sc.next();
        String y=n.substring(0,4),m=n.substring(4,6),d=n.substring(6);
        System.out.printf("year=%s\nmonth=%s\ndate=%s",y,m,d);
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

💯Analysis of ideas

       The idea of ​​this topic is: "Use substring to intercept"
  • 1

✍ Conclusion

By brushing more questions, we can enter the big factory as soon as possible and consolidate the knowledge we have learned. See you in the next issue, and subscribe to the column to brush the questions so as not to get lost.
👉Click to start free questioning and follow the blogger to the top 💪


Author: KJ.JK

If the article is helpful to you, you are welcome to give a like or star. Your support is the greatest encouragement to the author. If you have any shortcomings, you can correct them in the comment area to exchange and learn.

Related: Java Brush Questions Interview Series Exercises (8)