Primitive data types questions in java

Data type mcq questions of java and answers


(1)

class Datatype {
    public static void main(String[] args) {
         byte num=(byte)130;
         System.out.print(num);
    }
}

What will be the output when you compile and run the above code?
         
(a)130
(b)3
(c)-126
(d)Compiler error





Answer: (c)

(2)

class Datatype {
    public static void main(String[] args) {
         byte num=130;
         System.out.print(num);
    }
}

What will be the output when you compile and run the above code?

(a)130
(b)3
(c)-126
(d)Compiler error





Answer: (d)

(3)

class Datatype {
   
    public static void main(String[] args) {  
         byte number=0101;
         System.out.print(number);
    }
}

What will be the output when you compile and run the above code?

(a)101
(b)65
(c)5
(d)Compiler error





Answer: (b)

(4)

class Datatype {
    public static void main(String[] args) {  
         short num=0x8fff;
         System.out.print(num);
    }
}

What will be the output when you compile and run the above code?

(a)589823
(b)Infinity
(c)NaN
(d)Compiler error





Answer: (d)

(5)

class Datatype {
    public static void main(String[] args){  
         char num=65;
         System.out.println(num);
    }
}

What will be the output when you compile and run the above code?

(a)65
(b)A
(c)0
(d)Compiler error





7 comments:

nakshatra said...

This post is very simple to read and appreciate without leaving any details out. Great work!
data analytics courses
tableau course and certification
best data science courses
360DigiTMG

nakshatra said...

I wanted to leave a little comment to support you and wish you a good continuation. Wishing you the best of luck for all your blogging efforts.
data analytics courses
tableau course and certification
best data science courses
360DigiTMG

Data Science pune said...

Such a very useful article. Very interesting to read this article. I would like to thank you for the efforts you had made for writing this awesome article.
Data Science Course in Pune
Data Science Training in Pune

Data Science Institute In Banglore said...

Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.
Data Science Institute in Bangalore

Data Science Certification In Bangalore said...

Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!
Data Science Certification in Bangalore

DataScience Datascience said...

I must say, I thought this was a pretty interesting read when it comes to this topic. Liked the material. . . . .
Data Science Course in Bangalore

DataScience Datascience said...

Well, this got me thinking what other workouts are good for those of us who find ourselves on the road or have limited equipment options.
Data Science Training in Bangalore