Lecture 11: Java Operators Solution
Java Operators exercise
Assign '40 - 13' to a 'byte' data type named 'answer5'Java Operators solution
byte answer5 = 40 - 13;
public class Lecture11 {
public static void main(String[] args) {
// TODO: Assign ‘40 – 13 to a ‘byte’ data type named ‘answer5’
}
}
Hi there, again, My name is Marius from AlefTav Coding. In this lecture you will learn the solution to the Java operator coding exercise.
This exercise asks you to Assign '40 - 13' to a byte data type named 'answer5'.
In the solution, again, you use the Java pattern, dataType storageName = value. The problem statement says that the data type must be a byte. Next, it says the storage name must be answer5. Finally, the value you need to store is, 40 - 13 (40 minus 13). Java calculates the answer of this expression and puts it at the storage location named answer5.
So, my program has a class, named as Lecture11 with one method, main(). Remove the TODO comment and type the solution, data type as byte. Then, storage name as answer5 initialized to the expression, 40 - 13 and followed by a semi-colon.
In this lecture you learned the solution to the operator coding exercise.
So far you have learned how to use Java's primitive data types. In the next lecture I will look at Java's reference data types.
I am Marius from AlefTav Coding, and, as always, my signing off is to KEEP CODING.
Please be reminded to upvote, re-steem and share. For more of this you can find me at the following links.
https://busy.org/@mariusclaassen
https://steemit.com/@mariusclaassen
https://d.tube/#!/c/mariusclaassen
https://www.udemy.com/java-8-for-complete-beginners/learn/v4/overview