By using our mini forum, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy

Q: Assign Variables - Java Task

+8 votes

Find suitable types for variables. You are given the following types: byte, short, int, long, char, boolean, float, double, and String. Assign the following values to them false, “Palo Alto, CA”, 32767, 2000000000, 0.1234567891011, 0.5f, 919827112351L, 127, ‘c’. Try to assign 32768 to short and see what happens.

asked in Java category by user andrew
edited by user golearnweb

1 Answer

+1 vote
Best answer

This task is for beginners and has nothing complicated in it! :-) Here is my solution:

public class AssignVariables03 {
    public static void main(String[] args) {
        byte input1 = 127;
        short input2 = 32767;
        int input3 = 2000000000;
        long input4 = 919827112351L;
        char input5 = 'c';
        boolean input6 = false;
        float input7 = 0.5f;
        double input8 = 0.1234567891011;
        String inout9 = "Palo Alto, C";


answered by user eiorgert
selected by user golearnweb