Venkata Sai has Published 72 Answers

Are true and false keywords in java?

Venkata Sai

Venkata Sai

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

Keywords − Keywords in Java convey a special meaning to the compiler therefore, these cannot be used as identifiers. Java provides a set of 50 keywords.abstractcontinuefornewswitchassertdefaultgotopackagesynchronizedbooleandoifprivatethisbreakdoubleimplementsprotectedthrowbyteelseimportpublicthrowscaseenuminstanceofreturntransientcatchextendsintshorttrycharfinalinterfacestaticvoidclassfinallylongstrictfpvolatileconstfloatnativesuperwhileReserved words − Among the list of key words list mentioned above the key words goto and const are currently not in use. They are ... Read More

Differentiate between the prefix and postfix forms of the ++ operator in java?

Venkata Sai

Venkata Sai

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

Java provides two operators namely ++ and --, to increment and decrement values by 1 respectively.There are two variants of these operators −Pre-increment/decrement − This form, increments/decrements the value first, and then performs the specified operation.ExampleIn the following example, the initial value of the variable i is 5. We are ... Read More

What are the restrictions on increment and decrement operators in java?

Venkata Sai

Venkata Sai

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

The increment operator increments the value of the operand by 1 and the decrement operator decrements the value of the operand by 1. We use these operators to increment or, decrement the values of the loop after executing the statements on a value.Example Live Demopublic class ForLoopExample {    public static ... Read More

Can a for statement loop infinitely in java?

Venkata Sai

Venkata Sai

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

Using loops in programming languages we can execute a set of statements repeatedly. Java provides various loops namely while loop, for loop and the do while loop.The for statement contains an initialization statement, a condition and, an increment or decrement operation.Initializing statement − The initialization determines the starting value of ... Read More

What is shallow copy? Explain with an example in Java.

Venkata Sai

Venkata Sai

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

Creating an exact copy of an existing object in the memory is known as cloning.The clone() method of the class java.lang.Object accepts an object as a parameter, creates and returns a copy of it (clones).In order to use this method, you need to make sure that your class implements the ... Read More

What is deep copy? Explain with an example in Java.

Venkata Sai

Venkata Sai

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

Creating an exact copy of an existing object in the memory is known as cloning.The clone() method of the class java.lang.Object accepts an object as a parameter, creates and returns a copy of it (clones).In order to use this method, you need to make sure that your class implements the ... Read More

Explain widening with objects in Java.

Venkata Sai

Venkata Sai

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

Java provides various datatypes to store various data values. It provides 7 primitive datatypes (stores single values) namely, boolean, byte, char, short, int, long, float, double and, reference datatypes (arrays and objects).Type Casting/type conversion − Converting one primitive datatype into another is known as type casting (type conversion) in Java. ... Read More

Explain narrowing with object in Java.

Venkata Sai

Venkata Sai

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

Java provides various datatypes to store various data values. It provides 7 primitive datatypes (stores single values) namely, boolean, byte, char, short, int, long, float, double and, reference datatypes (arrays and objects).Type Casting/type conversion −Converting one primitive datatype into another is known as type casting (type conversion) in Java. You ... Read More

Explain Java command line arguments.

Venkata Sai

Venkata Sai

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

You can pass n number of arguments from the command line while executing the program, separating them with spaces.java ClassName 10 20 30 . . . . .The main method accepts/reads the values you have passed into an array of the type String.public class    public static void main(String[] args){ ... Read More

How to convert an object array to an integer array in Java?

Venkata Sai

Venkata Sai

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

You can convert an object array to an integer array in one of the following ways −By copying each element from integer array to object array −Exampleimport java.util.Arrays; public class ObjectArrayToStringArray {    public static void main(String args[]){       Object[] objArray = {21, 58, 69, 33, 65};   ... Read More

Advertisements