Welcome to CodeYourCraft's comprehensive guide on Java Interview Questions for beginners and intermediates! Let's dive into the world of Java together. 💡
Java is a high-level, object-oriented programming language developed by Sun Microsystems (now owned by Oracle). It's widely used for developing desktop applications, Android apps, and web applications.
Variables in Java are used to store data. Java has several built-in data types, including:
byte: 8-bit signed two's complement integer.short: 16-bit signed two's complement integer.int: 32-bit signed two's complement integer.long: 64-bit signed two's complement integer.float: single precision floating-point.double: double precision floating-point.char: 16-bit Unicode character.boolean: true or false.public class Main {
public static void main(String[] args) {
byte myByte = 10; // Assigning a byte value
short myShort = 20; // Assigning a short value
int myInt = 30; // Assigning an int value
long myLong = 40L; // Assigning a long value (Note the L at the end)
float myFloat = 5.5F; // Assigning a float value (Note the F at the end)
double myDouble = 6.6; // Assigning a double value
char myChar = 'A'; // Assigning a char value
boolean isTrue = true; // Assigning a boolean value
// Printing the variables
System.out.println("Byte: " + myByte);
System.out.println("Short: " + myShort);
System.out.println("Integer: " + myInt);
System.out.println("Long: " + myLong);
System.out.println("Float: " + myFloat);
System.out.println("Double: " + myDouble);
System.out.println("Char: " + myChar);
System.out.println("Boolean: " + isTrue);
}
}What is the difference between `long` and `int` data types in Java?
Operators in Java are used to perform operations on variables and values. Here are some common ones:
+, -, *, /, %=, +=, -=, *=, /=, %===, !=, <, >, <=, >=&&, ||, !What is the purpose of the `%` operator in Java?
Stay tuned for more on Java! 📝
Note: This is just a part of the Java Interview Questions - Core tutorial. If you find it helpful, feel free to explore more of CodeYourCraft's resources. Happy learning! 🎉