Venkata Sai has Published 62 Articles

Can we use Switch statement with Strings in java?

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

9K+ Views

A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case.Syntaxswitch(expression) {    case value :       // Statements       break;    case value : ... Read More

How to implement constants in java?

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

1K+ Views

A constant variable is the one whose value is fixed and only one copy of it exists in the program. Once you declare a constant variable and assign value to it, you cannot change its value again throughout the program.You can create a constant in c language using the constant ... Read More

What are the rules to be followed while making a variable static and final?

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

227 Views

Static variables − Static variables are also known as class variables. You can declare a variable static using the keyword. Once you declare a variable static there would only be one copy of it in the class, regardless of how many objects are created from it.public static int num = ... Read More

How do we copy objects in java?

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

8K+ Views

In Java you can copy an object in several ways, among them, copy constructor and the clone method are the mostly used.Using copy constructorGenerally, the copy constructor is a constructor which creates an object by initializing it with an object of the same class, which has been created previously. Java ... Read More

What are copy constructors in Java?

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

4K+ Views

Generally, the copy constructor is a constructor which creates an object by initializing it with an object of the same class, which has been created previously.Java supports for copy constructors but unlike C language, Java does not provide an explicit copy constructor you need to define it yourself.writing a copy ... Read More

Why is operator overloading not supported by java?

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

9K+ Views

When a class has two or more methods by the same name but different parameters, at the time of calling based on the parameters passed respective method is called (or respective method body will be bonded with the calling line dynamically). This mechanism is known as method overloading.Operator overloadingOperator overloading ... Read More

What are the restrictions placed on method overloading in java?

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

735 Views

When a class has two or more methods by the same name but different parameters, at the time of calling based on the parameters passed respective method is called (or respective method body will be bonded with the calling line dynamically). This mechanism is known as method overloading.Example Live Democlass Test{ ... Read More

Can we overload a method based on different return type but same argument type and number, in java?

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

8K+ Views

When a class has two or more methods by the same name but different parameters, at the time of calling based on the parameters passed respective method is called (or respective method body will be bonded with the calling line dynamically). This mechanism is known as method overloading.Exampleclass Test{ ... Read More

What value does read() method return when it reaches the end of a file in java?

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

917 Views

The read() method of the input stream classes reads the contents of the given file byte by byte and returns the ASCII value of the read byte in integer form. While reading the file if it reaches the end of the file this method returns -1.ExampleAssume we have a text ... Read More

What is EOFException in Java? How do we handle it?

Venkata Sai

Venkata Sai

Updated on 30-Jul-2019 22:30:26

3K+ Views

While reading the contents of a file in certain scenarios the end of the file will be reached in such scenarios a EOFException is thrown.Especially, this exception is thrown while reading data using the Input stream objects. In other scenarios a specific value will be thrown when the end of ... Read More

Advertisements