Java Question 59130500249 - muksuda/IdvdGame2 GitHub Wiki
-
Why is Java called the “Platform Independent Programming Language”? Answer : Becuase Java source code is compiled to bytecode by using Javac as a Java is a multiplatform, so Java can run on any platform
-
What is the difference between JDK and JRE? Answer : Both are Java virtua Machine JDK use for developing Java application and applets and JRE is a part of JDK it use for Java programs run on
-
What are the primitive data types supported by Java? What is “Autoboxing and Unboxing”? Answer : Primative data types supported by Java are byte,short, int,long,float,double,boolean and char. Autoboxing and unboxing are features added in Java. Autoboxing is a data that automatically chang data types without error and do not need to casting object in class,if it go to other ways is called unboxing
-
What does the “static” keyword as seen in “public static void main(String[] args)” mean?
Answer : a keyword identifies the class related thing. This means the given Method or variable is not instance related but Class related. It can be accessed without creating the instance of a Class. it mean you can call variable or method and no need to declare a new object of the class
-
Why can’t you access “non-static variables” in the “static” context? Answer : non-static variables are instance variables which are available only when an instance of the class is created.
-
What is a constructor? What does a “default constructor” look like? Answer : Constructure is follow by the class name ,create object from a class and have any parameter in side in default constructure is automatically compiler, int is 0, double 0.0 ,false for boolean and do not have any order in default constructure.
-
What is the difference between String s1 = new String(“CSC105”); and String s2 = “CSC105”;? Answer : String s1 = new String(“CSC105”); is using string literal "CSC105" in constructor,creates a new referentially distinct instance of string object.But, String s2 = “CSC105”; is reuse the instance that already stored value in string constant
-
What is the difference between the “==” operator and the “equals” method? Answer : "==" operator compares the two object references and determines whether they refer to the same instance or int the condition check in if else equals is a method available in the String class that is used to compare two strings
-
What is the difference between the “String”, “StringBuilder”, and “StringBuffer” classes? Answer : String once created can not be chang store in the constant string pool StringBuffer and StringBuilder almost the same, can change store int the heap StringBuffer each method in string is sychonized is thread safe but StringBuilder is fast as it is not thread safe
-
What is the difference between the “final” keyword and the “finally” keyword? Answer : Final is declared and the value can not change. Finally use with try-catch always executed after try or catch block is completed
-
What are Java’s “enum” classes? Answer : a variable to be a set of predefined constants. The variable that have not many possible value
-
What are the basic “Interfaces” of the Java Collections Framework (JCF)? Answer : Interfaces is the method that can hold the value in the same variable differenct data types.