Java Flashcards
what is JDK?
Java Development Kit and it’s used to create and run java programs
Main Method?
It is the entry point of any java program and like any other method it has a number of statements that execute a number of operations
Can reserved keywords used in any order?
no reserved keywords must be used in a specific order like public static void can’t be public void static
Statement
is a complete command to be executed and can contain one or more expressions
Variables
are a way to store our information in Ram
Declaration Statement
used to define a variable by giving it a datatype and a name and optionally an expression to set the initial value
how many data types are in java and what are they?
they r eight … int , float , double ,short , long , char , boolean , byte
Wrapper class
there is a wrapper class for each primitive type to be able to deal with the primitive types like methods and such
what are overflow and underflow?
is to exceed to maximum number or minimum number which in turn just skips to the opposite direction
how many bits does byte , short , int , long occupy in memory?
8 , 16 , 32 , 64
Casting
is the process of converting on type to another using (type)
which occupies more memory and has more percision float or double?
double has 64 bit and more precise while float has 32 bit
should we use float or double for precise calculations?
No. we should use BigDecimal class due to limitations of how float and double are stored in memory and that’s not a java problem
is Char type 1 byte or 2 bytes
it’s 2 bytes because it allows unicode to be stored meaning it’s 16 bit
Unicode
it’s an international encoding standard to represent characters or digits or symbols as unique numerics
what is a string?
a string is an immutable class of characters back to back which means it’s can’t be changed instead it is created again and the variable is assigned the new value and using this method is actually inefficient and better use StringBuffer
Operator
is a special symbol that performs an operation on two or more operands
Conditional logic
allow us to check to check for a condition and based on the result a certain piece of code is executed
Method OverLoading
it’s a feature that allows us to use the same name of method but different parameters meaning different implementations
an example of built in java overloading?
println
benefits of overloading
increase readability and re-usability and it’s easier to remember one method and achieves consistency in naming and flexibility
how to parse string
using wrapper.Parseprimitivetype
like Integer.parseint()
how to read user input?
by using the scanner class Scanner scanner = new Scanner(System.in) scanner.nextline() scanner.nextint()
do u have to create the constructor manually?
No java has a default constructor