StaticPL/JAVA
-
Access ModifierStaticPL/JAVA 2020. 2. 23. 22:50
1. Overview 2. Example 2.1 private class A{ private int data=40; private void msg(){System.out.println("Hello java");} } public class Simple{ public static void main(String args[]){ A obj=new A(); System.out.println(obj.data);//Compile Time Error obj.msg();//Compile Time Error } } class A{ private A(){}//private constructor void msg(){System.out.println("Hello java");} } public class Simple{ pub..
-
Is-A and Has-A Relationship in JavaStaticPL/JAVA 2020. 2. 5. 20:39
1. Overview IS-A Relationship: The concept of IS-A is totally based on Inheritance, which can be of two types Class Inheritance or Interface Inheritance. It is just like saying "A is a B type of thing". For example, Apple is a Fruit, Car is a Vehicle etc. Inheritance is uni-directional. For example, House is a Building. But Building is not a House. It is a key point to note that you can easily i..
-
Boxing, unboxing, and autoboxingStaticPL/JAVA 2019. 9. 27. 11:20
1. Overview Let's clarify what boxing, unboxing, and autoboxing are and Why it needs and how to work. 2. Description 2.1 Definition Name Definition Invoking cases Autoboxing Converting a primitive value into an object of the corresponding wrapper class Passed as a parameter to a method that expects an object of the corresponding wrapper class Assigned to a variable of the corresponding wrapper c..
-
FunctionalStaticPL/JAVA 2019. 8. 27. 20:46
1. Overview The term Java functional interface was introduced in Java 8. A functional interface in Java is an interface that contains only a single abstract (unimplemented) method. A functional interface can contain default and static methods which do have an implementation, in addition to the single unimplemented method. 1.1 Without Implementation public interface MyFunctionalInterface { public..
-
Generics and Generic MethodsStaticPL/JAVA 2019. 8. 27. 11:45
1. Overview Generic was designed to extend Java's type system to allow "a type or method to operate on objects of various types while providing compile-time type safety". The aspect of compile-time type safety was not fully achieved since it was shown in 2016 that it is not guaranteed in all classes. 2. Motivation Ensure type safety Ensure that generics wouldn't cause an overhead at runtime whic..
-
ReflectionStaticPL/JAVA 2019. 8. 27. 08:40
1. Overview It stands for modifying or examing the behavior of methods, classes, and interfaces at runtime. java.lang.reflect packages required classes for reflection It gives us information about the class to which an object belongs and also the methods of that class which can be executed by using the object. Being able to invoke methods at runtime irrespective of the access specifier used with..
-
Checked and Unchecked ExceptionsStaticPL/JAVA 2019. 8. 23. 17:30
1. Overview Let's distribute Java exceptions into two main categories: checked exceptions and unchecked exceptions. 2. Description 2.1 Checked Exceptions Represent errors outside the control of the program. Such as IOException, SQLException, and ParseException. Exception is the superclass of these Exceptions The constructor of FileInputStream throws FileNotFoundException if the input file does n..
-
Fork Join frameworkStaticPL/JAVA 2019. 8. 23. 12:58
1. Overview The fork/join framework was presented in Java 7. It provides tools to help speed up parallel processing by attempting to use all available processor cores – which is accomplished through a divide and conquer approach. In practice, this means that the framework first “forks”, recursively breaking the task into smaller independent subtasks until they are simple enough to be executed as..