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





14 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

Best Data Science Courses 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

123456789 said...

Ecommerce statistics access services, as it can be seen, wished the help of professionals who are widely recognized with those elements.data entry ecommerce

Machine Learning Course in Raipur - 360DigiTMG said...

Highly appreciable regarding the uniqueness of the content. This perhaps makes the readers feels excited to get stick to the subject. Certainly, the learners would thank the blogger to come up with the innovative content which keeps the readers to be up to date to stand by the competition. Once again nice blog keep it up and keep sharing the content as always.

360DigiTMG Business Analytics Course

Machine Learning Course in Raipur - 360DigiTMG said...

Terrific post thoroughly enjoyed reading the blog and more over found to be the tremendous one. In fact, educating the participants with it's amazing content. Hope you share the similar content consecutively.

360DigiTMG Data Analytics Course

kenwood said...

This is similar to commercial software that eventually becomes unsupported and requires replacement. unindent does not match any outer indentation level

Farhan.Jee said...

Not many people have the required skills to become a good data scientist. Therefore, this field is not as saturated as other fields in the IT sector. So, this field is vast and provides tons of opportunities. data science course syllabus

Harry jack said...

We exceptionally demoralize any programming for client ventures as it nullifies the point of an out-of-the case arrangement. We encourage clients to move toward any programming increments with alert. besimple.com/

Ashok said...

I just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page!
Artificial Intelligence Course