ExpertKelish Rai
Technical Content Writer @Programiz
Answered 89 questions
About
Hi, I'm Kelish, Technical Content Writer at Programiz. I break down complex programming concepts and turn them into easy-to-understand articles, tutorials, and courses. I'm also a developer at heart—I love solving coding problems, exploring algorithms, and staying updated with the latest tech stuff. If I'm not writing content, there's a good chance I'm working on a side project.

I understand that you're hearing mixed opinions about Java.
For beginners, Java can feel a bit overwhelming at first, mainly because it has more rules and structure compared to some other languages like Python. For example, in Python you can print something with just:
print("Hello")But in Java, even the simplest program needs a full structure like this:
public class Main {
public static void main(String[] args) {
System.out.println("Hello");
}
}This extra structure can feel like a lot when you're just starting out.
However, once you get the hang of it—just like with any other language—it becomes much easier and more natural to work with. You’ll soon feel comfortable using Java to write code.
Also, the structure and rules that might seem tough at first are actually what make Java so powerful and widely used in the industry. Its strictness helps avoid many bugs and makes large-scale software development more manageable.
Java is also used in a lot of real-world applications—from Android apps to banking systems—so the effort you put in can really pay off.
The key, as with anything, is to take it step by step. Once you're comfortable with the basics, it’ll start making more sense. It might feel challenging at the start, but with practice, it’ll definitely get smoother.

Deciding between a for loop, a while loop, and a while True loop mostly depends on whether you know when the loop should stop.
An easy way to think about it is:
1. If you know ahead of time how many times the loop should run (like looping through numbers from 1 to 10), a for loop is usually the better choice. For example,
for i in range(5):
print("Hello", i)This will print "Hello" five times. You clearly know it runs 5 times.
2. If you don’t know exactly how many times the loop should run and you're waiting for a certain condition to be met (like user input), a while loop makes more sense.
number = int(input("Enter a number (0 to stop): "))
while number != 0:
print("You entered:", number)
number = int(input("Enter a number (0 to stop): "))Here, you keep asking for input until the user enters 0. You don’t know how many times that will be, so while is a better fit.
3. while True is a special case used when you want an infinite loop that stops only when a condition inside the loop tells it to break. It’s powerful but should be used carefully.
while True:
command = input("Type 'exit' to stop: ")
if command == 'exit':
break
print("You typed:", command)Here, the loop keeps running no matter what until the user types "exit". It’s flexible, but if you forget the break or the condition is wrong, the loop may never stop.

The reason we create variables is to store values in a way that makes our code easier to manage and update.
Take this example:
print("Hi everyone!")
print("Hi everyone!")
print("Hi everyone!")
print("Hi everyone!")Now, suppose you want to greet your friend instead, say Alice. You’d have to manually change every line:
print("Hi Alice!")
print("Hi Alice!")
print("Hi Alice!")
print("Hi Alice!")That can get repetitive and time-consuming, especially as your program grows. But if you use a variable, things get much simpler:
greeting = "Hi everyone!"
print(greeting)
print(greeting)
print(greeting)
print(greeting)
print(greeting)Now, to greet Alice, you only need to change the value in one place:
greeting = "Hi Alice!"
print(greeting)
print(greeting)
print(greeting)
print(greeting)
print(greeting)As you can see, variables help save time and make your code more flexible. And when you're working with more data or writing bigger programs, they become even more useful.

Yes, you can technically use void main() instead of int main(). However, it's not recommended.
According to the C++ standard, the correct and portable way to define the main function is:
int main() {
// your code here
return 0;
}This version is universally accepted and ensures that your program can properly communicate with the operating system. The return 0; statement signals that the program finished successfully.
If you use void main(), you won't be able to use return 0; because the function doesn’t return anything. That might not cause an error in some compilers, but it's considered non-standard and could lead to unpredictable behavior or reduced portability.
In short:
Use
int main()for standard, portable, and reliable C++ code.void main()might work in some environments, but it’s not guaranteed.

Data types in most programming languages follow a similar concept, and Java and Python are no exception. However, there is an important distinction to understand between the two.
Java is a statically typed language, meaning that when you declare a variable, you must specify its data type upfront (like int, String, etc.). This can make your code more structured, but it also requires you to be more specific.
int age = 25;
String name = "Alice";On the other hand, Python is dynamically typed. You don't need to declare a variable's type explicitly — Python figures it out for you based on the value assigned to the variable. This makes Python a bit more flexible and easier for beginners to start with.
age = 25
name = "Alice"Even though the concept of data types (like numbers, strings, booleans) is present in both Java and Python, the way they're handled is different because of static vs dynamic typing.

In JavaScript, variable names cannot start with a number. They need to begin with a letter, an underscore (_), or a dollar sign ($). However, you can use numbers in the middle or at the end of the variable name.
For example, these are valid variable names:
myVariable1variable_2$_value
But these are not valid:
1stVariable123name
Note: If you try to start a variable name with a number, JavaScript will throw a syntax error when you run the code.

A programmer is someone who writes code to instruct computers on how to perform tasks. It’s a bit like giving a computer a set of instructions in a language it understands, so it can run apps, websites, games, or even control hardware.
Programmers use various programming languages to communicate with computers. These languages are designed in a way that allows the computer to "read" and follow the instructions.
C is one of these languages, and it’s well-known for its efficiency and speed, which is why it's been used for so long, especially in system-level programming.
Consider a simple program like this:
#include
int main() {
printf("Hello, world!");
return 0;
} This program simply tells the computer to print "Hello, world!" to the screen. The programmer writes the instructions in C, and the computer executes them.

The difference between a compiler and an interpreter mostly comes down to how they translate our code into machine-understandable language:
A compiler converts the entire code at once, creating a separate file (like an executable) that can be run later. Once compiled, you don’t need the source code to run the program.
An interpreter, on the other hand, translates the code line by line as it runs the program. It doesn’t produce an executable file; instead, it processes the code directly during execution.
This difference affects several aspects of how the code is executed, like execution speed and error handling.
Here's an example to make the difference clearer:
1. Compiled language (e.g. C):
// hello.c
#include
int main() {
printf("Hello, world!\n");
return 0;
} You would first compile this using a compiler like gcc:
gcc hello.c -o helloThen run the compiled file:
./hello2. Interpreted language (like Python):
# hello.py
print("Hello, world!")You just run it directly with the Python interpreter:
python hello.pyNote: Some modern languages use both techniques. For example, Java code is compiled into bytecode, which is then interpreted (or further compiled) by the Java Virtual Machine (JVM).

That’s completely okay—positions in CSS can feel a bit tricky at first. The best way to get the hang of them is to experiment with different values in your code and observe how the output changes.
Now, let’s break down position: relative in a simple way.
When you apply position: relative to an element, it allows you to move that element relative to where it would have naturally appeared on the page. It doesn’t take the element out of the normal flow—it just lets you shift it a bit.
For example, imagine we have a div with this basic style:
.box {
width: 100px;
height: 100px;
background: red;
}Without any positioning, the browser places it in its default spot in the flow of the page.
Let's say you want to move this box 20px lower from where it currently is. You can do that like this:
.box {
position: relative;
top: 20px;
width: 100px;
height: 100px;
background: red;
}With position: relative and top: 20px, the box visually shifts down by 20px from its original location—but its original space is still preserved. That means other elements around it won’t move into the gap where it used to be.
You can also use left, right, or bottom in the same way to shift the element in other directions.

When you're first learning to code, it's a common tradition to start by displaying Hello, World!—it's a simple way to check that your code is working. This has been the go-to example for decades.
But there’s no rule that says you must write Hello, World!. If you’d rather write Hello, Computer! or something else, feel free to do that. The key thing is getting comfortable with printing to the screen.
For example:
print("Hello, World!")or you could just as easily do:
print("Hello, Computer!")