Basic Questions Flashcards
Is Java platform independent?
Yes. We can write java code on one platform and run it on another platform.
Explain public static void main(String args[])
Here public is an access modifier, which means that this method is accessible by any class.
static – static keyword tells that this method can be accessed without creating the instance of the class. Refer: Static keyword in java
void – this main method returns no value.
main – It is the name of the method.
String args[] – The args is an array of String type. This contains the command line arguments that we can pass while running the program.
What is javac ?
javac produces the java byte code from the source code written *.java file. JVM executes the bytecode to run the program.
What is class?
A class is a blueprint or template or prototype from which you can create the object of that class. A class has set of properties and methods that are common to its objects.
What is the base class of all classes?
java.lang.Object is the base class (super class) of all classes in java.
What is a wrapper class in Java?
A wrapper class converts the primitive data type such as int, byte, char, boolean etc. to the objects of their respective classes such as Integer, Byte, Character, Boolean etc
What is a path and classPath in Java?
Path specifies the location of .exe files. Classpath specifies the location of bytecode (.class files).
Different Data types in Java
byte – 8 bit short – 16 bit char – 16 bit Unicode int – 32 bit (whole number) float – 32 bit (real number) long – 64 bit (Single precision) double – 64 bit (double precision)
What is Unicode?
Java uses Unicode to represent the characters. Unicode defines a fully international character set that can represent all of the characters found in human languages.
What are Literals?
Any constant value that is assigned to a variable is called literal in Java
What is an Array?
An array is a collection (group) of fixed number of items. Array is a homogeneous data structure which means we can store multiple values of same type in an array but it can’t contain multiple values of different types. For example an array of int type can only hold integer values.
What is BREAK statement in java?
The break statement is used to break the flow sequence in Java.
break statement is generally used with switch case data structure to come out of the statement once a case is executed.
It can be used to come out of the loop in Java
byte
8 bit integer
short
16 bit integer
char
16 bit unicode