ExpertAbhay Jajodia
Answered 166 questions
About
Designer by day, web developer by night, and a full-time tech + gaming nerd in between. I'm always learning, always curious — chasing life's bonus levels, secret achievements, and power-ups like it's one big epic quest.

Hi there! It's understandable to wonder why we need different quotation marks for characters and strings in Java.
In Java, single quotes are used to represent a single character, while double quotes are used for strings that can include multiple characters. Let's break it down simply:
A character represents just one letter, digit, or symbol - like
'A','8', or'!'. Using single quotes tells Java that you refer to exactly one character.A string can be any collection of letters, digits, or symbols, even just one! So, something like
"Hello, World!"or even"A"or"8"is considered a string because it's seen as a list of characters.
The reason we have to use single quotes for characters is to help the Java compiler distinguish between a single character and a string. Without this distinction, it would be tough for Java to understand what data type you're working with.
Remember: Characters and strings are distinct data types in Java. Therefore, we use single quotes for characters and double quotes for strings so that Java can distinguish between the two.
Hope this helps clear things up! Feel free to ask if you have any more questions or need further clarification.

Hi M Idrees Gul,
It usually will not cause an error. The " " is just a space, used to make the output readable.
Without it, the text prints back to back:
cout << "Hey." << "Are you enjoying the course?";
Output:Hey.Are you enjoying the course?
With a space in between:
cout << "Hey." << " " << "Are you enjoying the course?";
Output:Hey. Are you enjoying the course?
So " " is not required for the program to run, it is just for nicer output.
If you have more questions, I am here to help 😊

Hi Harish Hansda,
No, Java class names cannot contain spaces. A class name must be a single identifier.
If you want multiple words, write them together using CamelCase, like this:
class MyFirstClass {
}
If you have more questions, I am here to help 😊

Hi Yichao,
In Java, length for an array is a field (a value stored in the array), not a method. That is why you write it without parentheses:
int[] nums = {1, 2, 3};
System.out.println(nums.length); // 3
Parentheses are only used for methods. For example, strings use a method:
String s = "abc";
System.out.println(s.length()); // 3
So the simple rule is: arrays use length, strings use length().
If you have more questions, I am here to help 😊

Hi Rana Adnan,
Yes, the element you want to position absolutely must be inside the parent in the HTML.
But one more important thing: it will be positioned relative to the nearest parent that has a position set like relative, absolute, or fixed. Most of the time we set the parent to position: relative; so the child stays inside that box.
Example:
.parent { position: relative; }
.child { position: absolute; top: 0; right: 0; }
If no parent has a position set, the absolute element is positioned relative to the page (the viewport/document), which is why it can jump to a weird place.
If you have more questions, I am here to help 😊

Hi s j,
In C, a string needs one extra character at the end called the null terminator '\0' to mark where the text ends.
So char name[20] has 20 slots total:
up to 19 slots for the characters you type
1 slot for
'\0'
That is why you can only store 19 normal characters, even though the array size is 20.
If you have more questions, I am here to help 😊

Hi Revathi Kasireddy,
print is not a variable. It is a built-in function that shows output on the screen.
A variable is something like greeting that stores a value:
greeting = "Merry Christmas"
print(greeting) # prints the value inside greeting
So print() displays a value, and the variable is what holds the value.
If you have more questions, I am here to help 😊

Hi Tanvi,
We use #include because it gives your program access to standard input and output functions like printf() and scanf().
Example:
#include
int main() {
printf("Hello");
return 0;
}
Without stdio.h, the compiler may not recognize printf() properly.
If you have more questions, I am here to help 😊

Hi 王宇杰,
In Python, the / operator always returns a float, so 25 / 5 becomes 5.0 even though it is a whole number.
If you want an integer result, use //:
print(25 // 5) # 5
If you have more questions, I am here to help 😊

Hi there! That's a great and very common question when starting to learn about variables in C programming.
To answer your question: You do not need to use int again to change the age variable and print it.
The int keyword is only used when you first declare a variable to specify that the variable is of type integer. Once you've declared the variable, you can change its value without redeclaring its type.
In your example:
#include
int main() {
// Create an int variable and print it
int age = 25; // Declare and initialize the variable
printf("%d ", age);
// Assign a new value and print it
age = 31; // Change the value of the already declared variable
printf("%d", age);
return 0;
} Initially, you declare int age = 25; to create an integer variable age and set its value to 25. After that, you can simply change the value using age = 31; without using int again. The printf function can then print the updated value without any further declarations.
Hope this helps! Feel free to ask if you have any more questions. 😊