Search the courses, subjects, tracks, games and features, or jump straight to a page.
5 cards from this section. Quick, good the night before a test.
List Java's eight primitive data types under their four groups.
Four types for whole numbers, two for decimals, one for characters and one for true or false.
Choose the most suitable primitive type for each value: (a) the number of students in a class, (b) a percentage such as 87.5, (c) a grade such as B, (d) whether a library book has been returned, (e) the world's population.
Ask whether the value is whole, decimal, a single character or a yes/no answer, and how large it can get.
What is the size of an int in Java?
Byte, short, int and long double in size each time, starting from 8 bits.
Which of these declarations compiles?
Look for the right suffixes.
A student wants to add 1 to the largest int and keep the answer in a long, and writes long wrong = big + 1; where big holds Integer.MAX_VALUE. The answer printed is negative. Explain why, and show how to get 2147483648.
The type of the variable on the left does not change how the right-hand side is calculated.
Write a program that stores a student's roll number and marks out of 100 in five subjects (78, 85, 92, 66 and 89), then finds the total and the percentage, gives a grade (A for 80% or more, B for 60% or more, otherwise C) and records whether the student has a distinction (75% or more, the rule used in this program). Choose a suitable primitive type for each value.
Decide for each value whether it is whole, decimal, a single character or a yes/no answer.
6 more questions in this section. Enroll free to practise them all.
Enroll free