Java Basics

Chep
3 min readAug 3, 2023

--

What is Java?

  • Java is a popular programming language and development platform that was first released by Sun Microsystems in 1995. It is used for developing desktop and mobile applications, big data processing, embedded systems, and so on.

What are some of the benefits of Java?

  • Some key benefits of Java include:
  • Platform independent — Java code can run on any platform with a Java Virtual Machine (JVM).
  • Object oriented — Java supports object oriented programming features like classes, inheritance, polymorphism, etc.
  • Strong community — Java has a large community of developers who contribute libraries and tools.
  • Secure — Java runtime environment handles memory management and provides other security features.

What are objects and classes?

  • Objects are instances of classes. Classes are templates that define attributes and behaviors that are common to all objects of that class.

What is the main method signature?

  • The main method signature in Java is:
public static void main(String[] args){
//code goes in here
}

What is the difference between == and .equals()?

  • == tests for reference equality (whether they are the same object). .equals() tests for value equality (whether they have the same value).

What are the primitive data types in Java?

  • The primitive data types in Java are:
  • byte
  • short
  • int
  • long
  • float
  • double
  • boolean
  • char

What does ‘Debugging’ mean?

  • Debugging is the process of identifying and removing errors (bugs) from a program. It involves stepping through code, inspecting variables, and using logging to understand the flow and find issues.

What is String?

  • String is a class in Java that represents sequences of characters. Strings are immutable — once created, the value cannot be changed.

What is a Scanner?

  • Scanner is a class in Java that allows reading input from various sources, like the console or files. It is commonly used to read user input.

What is the compilation process in Java?

  • The compilation process in Java includes:
  • Editing the java code and storing in a file with .java extension.
  • The source code is compiled into bytecode by the javac compiler.
  • The JVM executes the bytecode.

Name a few operators in Java and what they do

  • Some common Java operators:
  • Arithmetic operators like +, -, *, /
  • Assignment =
  • Logical operators like &&, ||
  • Relational operators like <, >, ==
  • Increment/decrement operators like ++, —

What does the following operation do? x += 5; What is another way to write express this statement?

  • x += 5 is equivalent to x = x + 5. It increments the value of x by 5

What study habits do you find useful when learning new topics?

  • Practice writing code regularly
  • Break problems down into smaller parts
  • Use online courses or tutorials
  • Participate in coding challenges
  • Work on personal projects to apply your skills
  • Explain concepts to others

What does “full stack technology” mean?

  • Full stack technology refers to working with both the front-end and back-end portions of an application. It involves development skills for client-side (HTML, CSS, JavaScript) and server-side (databases, APIs, etc).

What is a flow control statement?

  • Flow control statements control the order in which code is executed. Examples include if/else statements, loops, switch statements.

Describe an if-else statement

  • An if-else statement executes code if a condition is true, and different code if the condition is false.
if (condition) { 
// code to execute if condition is true
} else {
// code to execute if condition is false
}

Describe a switch statement

  • A switch statement allows execution of different blocks of code depending on a variable’s value, instead of multiple if/else statements.
switch(variable) { 
case value1: // code block 1 break;
case value2: // code block 2 break;
//… default: // default code block
}

Describe a while-loop

  • A while loop executes a block of code repeatedly as long as a condition remains true.
while (condition) { 
// code to execute
}

Describe a do-while loop

  • A do-while loop is similar but checks the condition after executing the code block, so it will always execute at least once.
do { 
// code to execute
} while (condition);

Describe a for-loop

  • A for loop executes code a set number of times. It is useful when you need to iterate over something like an array.
for (initialization; condition; update) { 
// code to execute
}

What are the primitive data types in Java?(asked it TWICE because I NEED TO LEARN IT)

  • byte
  • short
  • int
  • long
  • float
  • double
  • boolean
  • char

--

--

Chep
Chep

Written by Chep

I've decided to write everyday for the rest of my life or until Medium goes out of business.

No responses yet