#JavaClass //Define class with class name Class - TopicsExpress



          

#JavaClass //Define class with class name Class MyFirstClass { // Instance variable int number = 11; // Method Void myFirstMethod(){ // Method doby //Local variable float price = 10.3f; ……………… …………….. } //Method ends //Constructor MyFirstClass(){ //No arguments constructor } //Constructor ends //Main Method public static void main(String[] agr){ …………………….. …………………………… ………………………………. } // Main Method Ends } // Class Ends #Class :- Java class is nothing but a template for object you are going to create it’s a blue print by using this we create an object. In between Class starting curly brace ‘ { ’ and ending ‘ } ’ , we can define instance variables, static variables (Class variables), local variables(Local variables are inside the method) and instance variables (are inside the class and outside the method). We can define different types of methods in a class and constructors. By default JVM provides default constructor, there is no arguments in a constructor . We can define class with Modifier :- public class MyFirstClass { …………… // body ……….. } Above we defined class with a public modifier. In the above first example, we defined class without modifier that is nothing but class is defined with a default modifier . #What is Tomorrow :- Tomorrow topic is about Modifiers(Access Modifiers and Non Access Modifiers) and class Variables .
Posted on: Fri, 11 Jul 2014 17:27:51 +0000

Trending Topics



Recently Viewed Topics




© 2015