- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Maruthi Krishna has Published 951 Articles
Maruthi Krishna
432 Views
The main purpose of constructors in Java is to initialize the instance variables of a class.But, if a class have Static variables you cannot initialize them using the constructors (you can assign values to static variables in constructors but in that scenario, we are just assigning values to static variables). ... Read More
Maruthi Krishna
377 Views
A code block/statement in Java to which the control never reaches and never gets executed during the lifetime of the program is known as unreachable block/statement.Generally, it happens whenever a piece of code hasA return statement before it.An infinite loop before it.Java does not support unreachable code. If you have ... Read More
Maruthi Krishna
863 Views
A code block/statement in Java to which the control never reaches and never gets executed during the lifetime of the program is known as unreachable block/statement.public class UnreachableCodeExample { public String greet() { System.out.println("This is a greet method "); return "Hello"; ... Read More
Maruthi Krishna
8K+ Views
An exception is an issue (run time error) occurred during the execution of a program. When an exception occurred the program gets terminated abruptly and, the code past the line that generated the exception never gets executed.Printing the Exception messageYou can print the exception message in Java using one of ... Read More
Maruthi Krishna
6K+ Views
Overloading is one of the mechanisms to achieve polymorphism. If a class contains two methods with the same name and different parameters, whenever you call this method the method body will be bound with the method call based on the parameters.ExampleIn the following Java program, the Calculator class has two ... Read More
Maruthi Krishna
669 Views
In Java a class is a user defined datatype/blue print in which we declare methods and variables.public class Sample{ }Once you declare a class you need to create an object (instantiate) it. You can create an object using various ways −Using new keywordIn general, an object is created using the ... Read More
Maruthi Krishna
699 Views
The equals() method compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object.Example Live Demopublic class Sample{ public static void main(String []args){ ... Read More
Maruthi Krishna
4K+ Views
The public static void main() method accepts an array of values of the type String Java from the user.public class{ public static void main(String[] args){ } }You can pass them at the time of execution right after the class name separated with spaces as −java ClassName 10 20 ... Read More
Maruthi Krishna
3K+ Views
The public static void main() method is the entry point of the Java program. Whenever you execute a program in Java, the JVM searches for the main method and starts executing from it.You can write the main method in your program with return type other than void, the program gets compiled ... Read More
Maruthi Krishna
2K+ Views
Static − If you declare a method, subclass, block, or a variable static it is loaded along with the class.In Java whenever we need to call an (instance) method we should instantiate the class (containing it) and call it. If we need to call a method without instantiation it should ... Read More