Object and class in Java

Nikitha N
Published on 23-Apr-2018 06:55:09
When we consider a Java program, it can be defined as a collection of objects that communicate via invoking each other's methods. Let us now briefly look into what do class, object means.Object − Objects have states and behaviors. Example: A dog has states - color, name, breed as well ... Read More

CamelCase in Java naming conventions

Ankitha Reddy
Published on 23-Apr-2018 06:51:13
Java follows camel casing for objects, class, variables etc. If a name is having multiple words, the first letter is small then consecutive words are joint with the first letter as a capital case. Consider the following example − Taxation Department Class - TaxationDepartment Object - taxationDepartment Method - getTaxationDepartmentDetails ... Read More

Advantages of naming conventions in Java

Syed Javed
Published on 23-Apr-2018 06:48:59
Following the the best practices while declaring a variable.  These best practices maintains code readability, understandability as project code size increases.Variables names should be short or long enough as per the scope. For example, loop counter variable, i is fine whereas employee as loop variable.Specific words should not be used ... Read More

Java Naming conventions

Ankitha Reddy
Published on 23-Apr-2018 06:46:21
All Java components require names. Names used for classes, variables and methods are called identifiers. In Java, there are several points to remember about identifiers. They are as follows - All identifiers should begin with a letter (A to Z or a to z), currency character ($) or an ... Read More

What is the purpose of private constructor in Java?

Syed Javed
Published on 23-Apr-2018 07:31:49
The private constructor is useful in case we want to restrict the object creation. For example, Singleton pattern can be implemented using a private constructor.ExampleLive Demopublic class Tester {    private static Tester instance;    private Tester(){}      public static Tester getInstance(){       if(instance == null){   ... Read More

How is down-casting possible in Java?

Syed Javed
Published on 23-Apr-2018 10:56:17
Yes, a variable can be downcast to its lower range substitute by casting. It may lead to data loss although. See the example below −ExampleLive Demopublic class Tester {      public static void main(String[] args) {       int a = 300;         byte b ... Read More

What is the difference between static and dynamic polymorphism?

Ankitha Reddy
Published on 22-Apr-2018 20:40:05
Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object. Method overriding by a subclass is termed as runtime polymorphism. JVM determines the method to ... Read More

What is runtime polymorphism or dynamic method overloading?

Ankitha Reddy
Published on 22-Apr-2018 20:42:39
Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object. Method overriding by a subclass is termed as runtime polymorphism. JVM determines the method to ... Read More

What is a marker or tagged interface in Java?

V Jyothi
Published on 23-Apr-2018 09:52:26
The most common use of extending interfaces occurs when the parent interface does not contain any methods. For example, the MouseListener interface in the java.awt.event package extended java.util.EventListener, which is defined as −Examplepackage java.util; public interface EventListener{ }An interface with no methods in it is referred to as a tagging ... Read More

What is static blank final variable in Java?

Syed Javed
Published on 22-Apr-2018 20:46:12
No. It is not allowed in Java. Compiler will fail the compilation throwing error that the blank final field may not have been initialized.
Advertisements