Search found 133 matches

by triapthisuresh
Wed Aug 31, 2016 4:47 pm
Forum: Java
Topic: How can you find the hash code of an object ?
Replies: 1
Views: 1490

Re: How can you find the hash code of an object ?

The hashCode( ) method of ‘Object’ class in java.lang.package is useful to find the hash code of
an object.
by triapthisuresh
Wed Aug 31, 2016 4:47 pm
Forum: Java
Topic: Can you declare a class as ‘private’ ?
Replies: 1
Views: 1534

Re: Can you declare a class as ‘private’ ?

No, if we declare a class as private , then it is not available to java compiler and hence a
compile time error occurs, But inner classes can be declared as private.
by triapthisuresh
Wed Aug 31, 2016 4:46 pm
Forum: Java
Topic: When is a constructor called, before or after creating the object ?
Replies: 1
Views: 1502

Re: When is a constructor called, before or after creating the object ?

A Constructor is called concurrently when the object creation is going on. JVM first allocates
memory for the object and then executes the constructor to initialize the instance variables. By the
time, object creation is completed, the constructor execution is also completed.
by triapthisuresh
Wed Aug 31, 2016 4:46 pm
Forum: Java
Topic: What is the difference between default constructor and parameterized constructor
Replies: 1
Views: 4737

Re: What is the difference between default constructor and parameterized constructor

Default constructor Parameter constructor Default constructor is useful to initialize all objects with same data. Parameterized constructor is useful to initialize each object with different data. Default constructor does not have any parameters. Parameterized constructor will have 1 or more paramet...
by triapthisuresh
Wed Aug 31, 2016 4:45 pm
Forum: Java
Topic: What is the difference between a constructor and a method
Replies: 1
Views: 1364

Re: What is the difference between a constructor and a method

A constructor is used to initialize the instance variables of a class. A mehtod is used for any general purpose processing or calcultaions. A constructor’s name and class name should be same. A mehtod’s name and class name can be same or different. A constructor is called at the time of creating obj...
by triapthisuresh
Wed Aug 31, 2016 4:45 pm
Forum: Java
Topic: What is constructor overloading ?
Replies: 1
Views: 1269

Re: What is constructor overloading ?

Writing two or more constructors with the same name but with difference in the parameters is
called constructor overloading. Such constructors are useful to perform different tasks.
by triapthisuresh
Wed Aug 31, 2016 4:44 pm
Forum: Java
Topic: What are instance methods ?
Replies: 1
Views: 1424

Re: What are instance methods ?

Instance methods are the methods which act on the instance variables of the class. To call the
instance methods , we should use the form; objectname.methodname( ).
Ex: double x = obj.sum( );
by triapthisuresh
Wed Aug 31, 2016 4:44 pm
Forum: Java
Topic: What are static methods ?
Replies: 1
Views: 1524

Re: What are static methods ?

Static methods are the methods which do not act upon the instance variables of a class. Static
methods are declared as ‘static’.
by triapthisuresh
Wed Aug 31, 2016 4:43 pm
Forum: Java
Topic: What is the difference between instance variables and class variables(static variables)
Replies: 1
Views: 1342

Re: What is the difference between instance variables and class variables(static variables)

). 1. An Instance variable is a variable whose separate copy is availabe to each object. A class
variable is a variable whose single copy in memory is shared by all objects.
2. Instance variables are created in the objects on heap memory. Class variables are stored on method
area.
by triapthisuresh
Wed Aug 31, 2016 4:43 pm
Forum: Java
Topic: Why instance Variables are not available to static methods ?
Replies: 1
Views: 1399

Re: Why instance Variables are not available to static methods ?

After executing static methods, JVM creates the objects. So the instance variables of the objects
are not available to static methods.

Go to advanced search