What are the set methods and get methods? The set methods are the methods in a class defined to set or change the values of the instance variables of that class. And the get methods are the methods to retrieve the values of the instance variables. Consider the Student class …
Read More »What is a constructor? How It is different from other methods?
What is a constructor? How It is different from other methods? What is a constructor: A constructor is a special method defined in a class implicitly or explicitly. Its purpose is to initialize the instance variables of a class. How It is different from other methods? Differences between Constructor and …
Read More »Introduction to classes and objects in Java
Introduction to classes and objects in Java: Class: Class is a template from which we create objects. Class is a cellection of objects. Object: Instance of a class is called object of that class. Objects are the reusable software components. There are different types of objects like date objects, time …
Read More »Sample Questions Part 1
Sample Questions and their answers: 1: What will be the output of the following program? public class Printing { public static void main(String[] args) { for(int i=1;i<=10;i++) { for(int j=1;j<=5;j++) System.out.print("*"); System.out.println(); } //end outer for }// end main }// end class printing Output is: ***** ***** ***** ***** ***** …
Read More »Performance Review Questions
Performance Review Questions Set 1: Differentiate an object and a class. What are constructors used for? How are they defined in a class? What is a modifier? How are overloaded methods distinguished from each other?
Read More »