Programming Basics Flashcards
How to output “ Hello World “ in CMD using Java?
public class Filename >1
{ >2
public static void main ( String[]args ) >3
{ >4
System.out.println(“Hello World”); >5
} >6
} >7
What does the world public mean in the first line of Java ?
- A keyword of Java language that indicates that the element that follows should be made available to other Java elements.
- Other class can also use it
What does the curly brackets ( {} ) do in 2nd line and the last line?
- Everything that are included in the curly brackets belongs to the class
What does the word void mean ?
- To indicate that no value is returned
- To let the program just run the program and return nothing
What does static mean ?
- To run the method without calling on the class
What does String [] args mean ?
- It is a parameter list
Why it was not advisable to create identifiers using the Java Keywords
- May lead to confusion
What is Java most concerned about ?
Case Sensitive
- for to For , it will be printing error
The most important programming tips
- Remember to semicolon ( ; )
- Remember to check if there is any word that are being written in Uppercase Letters
Java Keywords also known as
Reserved words
Statements format ( 5 )
1.Declaration Statement
- int i ;
- String name ;
- Assignment Statement
- i = 42 ;
- name = “ ADI “
- Declaration + Assignment
- int i = 42
- String name = “ ADI “
- Expression Statement
- System.out.println(“Hello World”)
- Many other more
- for
- if
Statement must type semicolon ( ; ) after finishing
- Declaration
- Expression
How can you create a block ?
- Using brace { }
Do we need to add semicolon after creating a block ?
No
Which is correct?
1. int Total
= 100;
2. int Total = 100;
Both are correct
What are double and float different ?
- double - to represent double-precision 64-bit floating-point numbers
- float - To represent single-precision 32-bit floating-point numbers
How to create a comment?
- Type // ( End-of-line Comments )
- Type /* */ ( Traditional Comments )
- ( Java DOC Comment )
All identifiers must begin with what?
Letter ( a , d , A)