Venkata Sai has Published 62 Articles

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

Venkata Sai

Venkata Sai

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

834 Views

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

6K+ Views

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

2K+ Views

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

2K+ Views

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

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

Venkata Sai

Venkata Sai

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

5K+ Views

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

Is main method compulsory in Java?

Venkata Sai

Venkata Sai

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

3K+ Views

To compile a program, you doesn’t really need a main method in your program. But, while execution JVM searches for the main method. In the Java the main method is the entry point Whenever you execute a program in Java JVM searches for the main method and starts executing from ... Read More

What is instance variable hiding in Java?

Venkata Sai

Venkata Sai

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

1K+ Views

Whenever you inherit a superclass a copy of superclass’s members is created at the subclass and you using its object you can access the superclass members.If the superclass and the subclass have instance variable of same name, if you access it using the subclass object, the instance variables of the ... Read More

What are the default array values in Java?

Venkata Sai

Venkata Sai

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

2K+ Views

In Java arrays are the reference types which stores multiple elements of the same datatype. You can create an array just like an object using the new keyword −type[] reference = new type[10];or, directly using the flower brackets ({}).int [] myArray = {10, 20, 30, 40, 50}When you create instance ... Read More

Java Program to find all angles of a triangle

Venkata Sai

Venkata Sai

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

413 Views

To find the angles of a triangle we can use sin/cosine rules according to cosine rule −cos A = (b^2 + c^2 - a^2)/2bcwhere A, B , C are the vertices and a, b, c are the sides of the given triangle then, angles of the triangle when the sides ... Read More

Java Programs for printing Pyramid Patterns. (of numbers)

Venkata Sai

Venkata Sai

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

175 Views

Following is a Java program which prints a pyramid of numbers.Example Live Demopublic class PrintingPyramids {    public static void main(String args[]){       int n,i,j,k=1;       n = 5;       for(i = 0; i

Advertisements