Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

611
LINES

< > BotCompany Repo | #3000030 // Contents of http://www.tutorialspoint.com/java/java_object_classes.htm

New Tinybrain snippet

<!DOCTYPE html>
<!--[if IE 8]><html class="ie ie8"> <![endif]-->
<!--[if IE 9]><html class="ie ie9"> <![endif]-->
<!--[if gt IE 9]><!-->	<html> <!--<![endif]-->
<head>
<!-- Basic -->
<meta charset="utf-8">
<title>Java - Object &amp; Classes</title>
<meta name="description" content="Java Object &amp; Classes - Learning Java in simple and easy steps : A beginner's tutorial containing complete knowledge of Java Syntax Object Oriented Language, Methods, Overriding, Inheritance, Polymorphism, Interfaces, Packages, Collections, Networking, Multithreading, Generics, Multimedia, Serialization, GUI." />
<meta name="keywords" content="Java, Tutorials, Learning, Beginners, Basics, Object Oriented Language, Methods, Overriding, Inheritance, Polymorphism, Interfaces, Packages, Collections, Networking, Multithreading, Generics, Multimedia, Serialization, GUI." />
<base href="http://www.tutorialspoint.com/" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=yes">
<meta name="author" content="tutorialspoint.com">
<meta property="fb:app_id" content="471319149685276" />
<script type="text/javascript" src="/theme/js/script-min-v4.js"></script>
<link rel="stylesheet" href="/theme/css/style-min-v5.css">
<!-- Head Libs -->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="/theme/css/ie8.css">
<![endif]-->
<!-- Front Page related changes -->
<style>
pre.prettyprint.tryit {background: #eee url(java/images/try-it.jpg) top right no-repeat !important}
div.feature-box div.feature-box-icon, .col-md-3 .course-box, li.heading, div.footer-copyright { background: #eb4847 url(/images/pattern.png) repeat center center !important;}
.sub-main-menu .sub-menuu div:hover, .sub-main-menu .viewall, header nav ul.nav-main li a:hover, button.btn-responsive-nav, header div.search button.btn-default { background: #eb4847 !important;}
.submenu-item{ border-bottom: 2px solid #eb4847 !important; border-top: 2px solid #eb4847 !important }
</style>
<script>
$(document).ready(function() {
  $('input[name="q"]').keydown(function(event){
    if(event.keyCode == 13) {
      event.preventDefault();
      return false;
    }
  });
});
</script>
</head>
<body onload="prettyPrint()">
<div class="wrapLoader">
   <div class="imgLoader">
      <img  src="/images/loading-cg.gif" alt="" width="70" height="70" />
   </div>
</div>
<header>
   <div class="container">			
      <h1 class="logo">
      <a href="index.htm" title="tutorialspoint">
      <img alt="tutorialspoint" src="/absoluteclasses/images/logo.png">
      </a>
      </h1>			
      <div class="search" id="searchBar">
         <form method="get" class="searchform" name="searchform" action="http://www.google.com/search" target="_blank">
            <input type="hidden" name="sitesearch" value="www.tutorialspoint.com">
            <div class="input-group">
               <input type="text" class="form-control search" name="q" autocomplete="off" placeholder="Search your tutorials..." onfocus="if (this.value == 'Search your tutorials...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search your tutorials...';}">
               <input value="FORID:11" name="cof" type="hidden">
               <input type="hidden" name="ie" value="ISO-8859-1">
               <span class="input-group-btn"> <button class="btn btn-default" type="submit" onclick="javascript:void(0);"><i class="icon icon-search"></i></button> </span>
            </div>
         </form>
      </div>
      <nav>
         <ul class="nav nav-pills nav-top">
            <li class="top-icons"> <a href="/free_online_whiteboard.htm"><i class="fa fa-desktop"></i> &nbsp;Whiteboard</a> </li>
            <li class="top-icons"> <a href="/questions_and_answers.htm"><i class="fa fa-question"></i> &nbsp;Quizzes</a> </li>
            <li> <a href="/shared-tutorials.php"><i class="icon icon-user"></i> &nbsp;Shared</a> </li>
            <li> <a href="/articles/index.php"><i class="icon icon-file-text-o"></i> &nbsp;Articles</a> </li>
            <li class="top-icons" style="display:none;"> <a href="job_search.php?search_string=jobs"><i class="fa fa-send"></i> &nbsp;Jobs</a> </li>

            <li class="top-icons" style="display:none;">
              <ul class="social-icons">
              <li class="facebook"><a href="https://www.facebook.com/tutorialspointindia" target="_blank" data-placement="bottom" title="tutorialspoint @ Facebook">Facebook</a></li>
              <li class="googleplus"><a href="https://plus.google.com/u/0/116678774017490391259/posts" target="_blank" data-placement="bottom" title="tutorialspoint @ Google+">Google+</a></li>
              <li class="twitter"><a href="http://www.twitter.com/tutorialspoint" target="_blank" data-placement="bottom" title="tutorialspoint @ Twitter">Twitter</a></li>
              <li class="linkedin"><a href="http://www.linkedin.com/company/tutorialspoint" target="_blank" data-placement="bottom" title="tutorialspoint @ Linkedin">Linkedin</a></li>
              <li class="rss"><a href="http://feeds.feedburner.com/SharedTutorials" target="_blank" data-placement="bottom" title="tutorialspoint RSS">RSS</a></li>
              </ul>
           </li>
         </ul>
      </nav>
         <!-- search code here  --> 
      <button class="btn btn-responsive-nav btn-inverse" data-toggle="collapse" data-target=".nav-main-collapse" id="pull"> <i class="icon icon-bars"></i> </button>
   </div>
   <div class="navbar nav-main">
      <div class="container">
         <nav class="nav-main mega-menu">
            <ul class="nav nav-pills nav-main" id="mainMenu">
               <li class="dropdown no-sub-menu"> <a class="dropdown" href="index.htm"><i class="icon icon-home"></i> Home</a> </li>   
               <li class="dropdown" id="liTL"><a class="dropdown tut-lib" href="javascript:void(0);"> Tutorials Library  <i class="fa-caret-down"></i> </a></li>
               <li class="dropdown" id="liCG"><a class="dropdown" href="javascript:void(0);"><i class="fa-code"></i> Coding Ground <i class="fa-caret-down"></i> </a> </li>
               <li class="dropdown no-sub-menu"><a class="dropdown tut-plus" href="/absoluteclasses/upcomingclasses.htm">Absolute Classes</a>
               </li>
            </ul>
         </nav>
         <div class="submenu-item sub-main-menu" id="top-sub-menu"></div>
      </div>
   </div>	
</header>
<div style="clear:both;"></div>
<div role="main" class="main">
<div class="container">
<div class="row">
<div class="col-md-2">
<aside class="sidebar">
  <div class="mini-logo">
<img src="/java/images/java-mini-logo.jpg" alt="Java Tutorial" />
</div>
<ul class="nav nav-list primary left-menu" >
<li class="heading">Java Tutorial</li>
<li><a target="_top" href="/java/index.htm">Java - Home</a></li>
<li><a target="_top" href="/java/java_overview.htm">Java - Overview</a></li>
<li><a target="_top" href="/java/java_environment_setup.htm">Java - Environment Setup</a></li>
<li><a target="_top" href="/java/java_basic_syntax.htm">Java - Basic Syntax</a></li>
<li><a target="_top" href="/java/java_object_classes.htm">Java - Object &amp; Classes</a></li>
<li><a target="_top" href="/java/java_basic_datatypes.htm">Java - Basic Datatypes</a></li>
<li><a target="_top" href="/java/java_variable_types.htm">Java - Variable Types</a></li>
<li><a target="_top" href="/java/java_modifier_types.htm">Java - Modifier Types</a></li>
<li><a target="_top" href="/java/java_basic_operators.htm">Java - Basic Operators</a></li>
<li><a target="_top" href="/java/java_loop_control.htm">Java - Loop Control</a></li>
<li><a target="_top" href="/java/java_decision_making.htm">Java - Decision Making</a></li>
<li><a target="_top" href="/java/java_numbers.htm">Java - Numbers</a></li>
<li><a target="_top" href="/java/java_characters.htm">Java - Characters</a></li>
<li><a target="_top" href="/java/java_strings.htm">Java - Strings</a></li>
<li><a target="_top" href="/java/java_arrays.htm">Java - Arrays</a></li>
<li><a target="_top" href="/java/java_date_time.htm">Java - Date &amp; Time</a></li>
<li><a target="_top" href="/java/java_regular_expressions.htm">Java - Regular Expressions</a></li>
<li><a target="_top" href="/java/java_methods.htm">Java - Methods</a></li>
<li><a target="_top" href="/java/java_files_io.htm">Java - Files and I/O</a></li>
<li><a target="_top" href="/java/java_exceptions.htm">Java - Exceptions</a></li>
<li><a target="_top" href="/java/java_innerclasses.htm">Java - Inner classes</a></li>
</ul>
<ul class="nav nav-list primary left-menu" >
<li class="heading">Java Object Oriented</li>
<li><a target="_top" href="/java/java_inheritance.htm">Java - Inheritance</a></li>
<li><a target="_top" href="/java/java_overriding.htm">Java - Overriding</a></li>
<li><a target="_top" href="/java/java_polymorphism.htm">Java - Polymorphism</a></li>
<li><a target="_top" href="/java/java_abstraction.htm">Java - Abstraction</a></li>
<li><a target="_top" href="/java/java_encapsulation.htm">Java - Encapsulation</a></li>
<li><a target="_top" href="/java/java_interfaces.htm">Java - Interfaces</a></li>
<li><a target="_top" href="/java/java_packages.htm">Java - Packages</a></li>
</ul>
<ul class="nav nav-list primary left-menu" >
<li class="heading">Java Advanced</li>
<li><a target="_top" href="/java/java_data_structures.htm">Java - Data Structures</a></li>
<li><a target="_top" href="/java/java_collections.htm">Java - Collections</a></li>
<li><a target="_top" href="/java/java_generics.htm">Java - Generics</a></li>
<li><a target="_top" href="/java/java_serialization.htm">Java - Serialization</a></li>
<li><a target="_top" href="/java/java_networking.htm">Java - Networking</a></li>
<li><a target="_top" href="/java/java_sending_email.htm">Java - Sending Email</a></li>
<li><a target="_top" href="/java/java_multithreading.htm">Java - Multithreading</a></li>
<li><a target="_top" href="/java/java_applet_basics.htm">Java - Applet Basics</a></li>
<li><a target="_top" href="/java/java_documentation.htm">Java - Documentation</a></li>
</ul>
<ul class="nav nav-list primary left-menu" >
<li class="heading">Java Interview Questions</li>
<li><a target="_top" href="/java/java_interview_questions.htm">Java - Interview Questions</a></li>
</ul>
<ul class="nav nav-list primary left-menu" >
<li class="heading">Java Useful Resources</li>
<li><a target="_top" href="/java/java_quick_guide.htm">Java - Quick Guide</a></li>
<li><a target="_top" href="/java/java_useful_resources.htm">Java - Useful Resources</a></li>
<li><a target="_top" href="/java/java_discussion.htm">Java - Discussion</a></li>
<li><a target="_top" href="/javaexamples/index.htm">Java - Examples</a></li>
</ul>
<ul class="nav nav-list primary push-bottom left-menu special">
<li class="sreading">Selected Reading</li>
<li><a target="_top" href="/developers_best_practices/index.htm">Developer's Best Practices</a></li>
<li><a target="_top" href="/questions_and_answers.htm">Questions and Answers</a></li>
<li><a target="_top" href="/effective_resume_writing.htm">Effective Resume Writing</a></li>
<li><a target="_top" href="/hr_interview_questions/index.htm">HR Interview Questions</a></li>
<li><a target="_top" href="/computer_glossary.htm">Computer Glossary</a></li>
<li><a target="_top" href="/computer_whoiswho.htm">Who is Who</a></li>
</ul>
</aside>
</div>
<!-- PRINTING STARTS HERE -->
<div class="row">
<div class="content">
<div class="col-md-7 middle-col">
<h1>Java - Object &amp; Classes</h1>
<div class="topgooglead">
<hr />
<div style="padding-bottom:5px;padding-left:10px;">Advertisements</div>
<script type="text/javascript"><!--
google_ad_client = "pub-7133395778201029";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "image";
google_ad_channel = "";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> 
</script>
</div>
<hr />
<div class="pre-btn">
<a href="/java/java_basic_syntax.htm"><i class="icon icon-arrow-circle-o-left big-font"></i> Previous Page</a>
</div>
<div class="nxt-btn">
<a href="/java/java_basic_datatypes.htm">Next Page <i class="icon icon-arrow-circle-o-right big-font"></i>&nbsp;</a>
</div>
<div class="clearer"></div>
<hr />
<p>Java is an Object-Oriented Language. As a language that has the Object Oriented feature, Java supports the following fundamental concepts:</p>
<ul class="list">
<li>Polymorphism</li>
<li>Inheritance</li>
<li>Encapsulation</li>
<li>Abstraction</li>
<li>Classes</li>
<li>Objects</li>
<li>Instance</li>
<li>Method</li>
<li>Message Parsing</li>
</ul>
<p>In this chapter, we will look into the concepts Classes and Objects.</p>
<ul class="list">
<li><p><b>Object -</b> Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors -wagging, barking, eating. An object is an instance of a class. </p></li>
<li><p><b>Class -</b> A class can be defined as a template/blue print that describes the behaviors/states that object of its type support.</p></li>
</ul>
<h2>Objects in Java:</h2>
<p>Let us now look deep into what are objects. If we consider the real-world we can find many objects around us, Cars, Dogs, Humans, etc. All these objects have a state and behavior.</p>
<p>If we consider a dog, then its state is - name, breed, color, and the behavior is - barking, wagging, running</p>
<p>If you compare the software object with a real world object, they have very similar characteristics.</p>
<p>Software objects also have a state and behavior. A software object's state is stored in fields and behavior is shown via methods.</p>
<p>So in software development, methods operate on the internal state of an object and the object-to-object communication is done via methods.</p>
<h2>Classes in Java:</h2>
<p>A class is a blue print from which individual objects are created.</p>
<p>A sample of a class is given below:</p>
<pre class="prettyprint notranslate">
public class Dog{
   String breed;
   int ageC
   String color;

   void barking(){
   }
   
   void hungry(){
   }
   
   void sleeping(){
   }
}
</pre>
<p>A class can contain any of the following variable types.</p>
<ul class="list">
<li><p><b>Local variables: </b>Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and the variable will be destroyed when the method has completed.</p></li>
<li><p><b>Instance variables: </b>Instance variables are variables within a class but outside any method. These variables are initialized when the class is instantiated. Instance variables can be accessed from inside any method, constructor or blocks of that particular class.</p></li>
<li><p><b>Class variables: </b>Class variables are variables declared with in a class, outside any method, with the static keyword.</p></li>
</ul>
<p>A class can have any number of methods to access the value of various kinds of methods. In the above example, barking(), hungry() and sleeping() are methods.</p>
<p>Below mentioned are some of the important topics that need to be discussed when looking into classes of the Java Language.</p>
<h2>Constructors:</h2>
<p>When discussing about classes, one of the most important sub topic would be constructors. Every class has a constructor. If we do not explicitly write a constructor for a class the Java compiler builds a default constructor for that class.</p>
<p>Each time a new object is created, at least one constructor will be invoked. The main rule of constructors is that they should have the same name as the class. A class can have more than one constructor.</p>
<p>Example of a constructor is given below:</p>
<pre class="prettyprint notranslate">
public class Puppy{
   public Puppy(){
   }

   public Puppy(String name){
      // This constructor has one parameter, <i>name</i>.
   }
}
</pre>


<p></p>
<p>Java also supports <a href="/java/java_using_singleton.htm">Singleton Classes</a> where you would be able to create only one instance of a class.</p>
<p><b>Note: </b>We have two different types of constructors we are going to discuss constructors in detail in coming chapters.</p>
<h2>Creating an Object:</h2>
<p>As mentioned previously, a class provides the blueprints for objects. So basically an object is created from a class. In Java, the new key word is used to create new objects. </p>
<p>There are three steps when creating an object from a class:</p>
<ul class="list">
<li><p><b>Declaration: </b>A variable declaration with a variable name with an object type.</p></li>
<li><p><b>Instantiation: </b>The 'new' key word is used to create the object.</p></li>
<li><p><b>Initialization: </b>The 'new' keyword is followed by a call to a constructor. This call initializes the new object.</p></li>
</ul>
<p>Example of creating an object is given below:</p>
<pre class="prettyprint notranslate tryit">
public class Puppy{

   public Puppy(String name){
      // This constructor has one parameter, <i>name</i>.
      System.out.println("Passed Name is :" + name ); 
   }
   
   public static void main(String []args){
      // Following statement would create an object myPuppy
      Puppy myPuppy = new Puppy( "tommy" );
   }
}
</pre>
<p>If we compile and run the above program, then it would produce the following result:</p>
<pre class="prettyprint notranslate">
Passed Name is :tommy
</pre>
<h2>Accessing Instance Variables and Methods:</h2>
<p>Instance variables and methods are accessed via created objects. To access an instance variable the fully qualified path should be as follows:</p>
<pre class="prettyprint notranslate">
/* First create an object */
ObjectReference = new Constructor();

/* Now call a variable as follows */
ObjectReference.variableName;

/* Now you can call a class method as follows */
ObjectReference.MethodName();
</pre>
<h2>Example:</h2>
<p>This example explains how to access instance variables and methods of a class:</p>
<pre class="prettyprint notranslate tryit">
public class Puppy{
   
   int puppyAge;

   public Puppy(String name){
      // This constructor has one parameter, <i>name</i>.
      System.out.println("Name chosen is :" + name ); 
   }
   
   public void setAge( int age ){
       puppyAge = age;
   }

   public int getAge( ){
       System.out.println("Puppy's age is :" + puppyAge ); 
       return puppyAge;
   }
   
   public static void main(String []args){
      /* Object creation */
      Puppy myPuppy = new Puppy( "tommy" );

      /* Call class method to set puppy's age */
      myPuppy.setAge( 2 );

      /* Call another class method to get puppy's age */
      myPuppy.getAge( );

      /* You can access instance variable as follows as well */
      System.out.println("Variable Value :" + myPuppy.puppyAge ); 
   }
}
</pre>
<p>If we compile and run the above program, then it would produce the following result:</p>
<pre class="prettyprint notranslate">
Name chosen is :tommy
Puppy's age is :2
Variable Value :2
</pre>
<h2>Source file declaration rules:</h2>
<p>As the last part of this section let's now look into the source file declaration rules. These rules are essential when declaring classes, <i>import</i> statements and <i>package</i> statements in a source file.</p>
<ul class="list">
<li><p>There can be only one public class per source file.</p></li>
<li><p>A source file can have multiple non public classes.</p></li>
<li><p>The public class name should be the name of the source file as well which should be appended by <b>.java</b> at the end. For example: the class name is <i>public class Employee{}</i> then the source file should be as Employee.java.</p></li>
<li><p>If the class is defined inside a package, then the package statement should be the first statement in the source file.</p></li>
<li><p>If import statements are present then they must be written between the package statement and the class declaration. If there are no package statements then the import statement should be the first line in the source file. </p></li>
<li><p>Import and package statements will imply to all the classes present in the source file. It is not possible to declare different import and/or package statements to different classes in the source file.</p></li>
</ul>
<p>Classes have several access levels and there are different types of classes; abstract classes, final classes, etc. we will be explaining about all these in the access modifiers chapter.</p>
<p>Apart from the above mentioned types of classes, Java also has some special classes called Inner classes and Anonymous classes.</p>
<h2>Java Package:</h2>
<p>In simple, it is a way of categorizing the classes and interfaces. When developing applications in Java,  hundreds of classes and interfaces will be written, therefore categorizing these classes is a must as well as makes life much easier.</p>
<h2>Import statements:</h2>
<p>In Java if a fully qualified name, which includes the package and the class name, is given then the compiler can easily locate the source code or classes. Import statement is a way of giving the proper location for the compiler to find that particular class.</p>
<p>For example, the following line would ask compiler to load all the classes available in directory java_installation/java/io :</p>
<pre class="prettyprint notranslate">
import java.io.*;
</pre>
<h2>A Simple Case Study</h2>
<p>For our case study, we will be creating two classes. They are Employee and EmployeeTest.</p>
<p>First open notepad and add the following code. Remember this is the Employee class and the class is a public class. Now, save this source file with the name Employee.java.</p>
<p>The Employee class has four instance variables name, age, designation and salary. The class has one explicitly defined constructor, which takes a parameter.</p>
<pre class="prettyprint notranslate" id="employee">
import java.io.*;

public class Employee{

   String name;
   int age;
   String designation;
   double salary;
	
   // This is the constructor of the class Employee
   public Employee(String name){
      this.name = name;
   }
   // Assign the age of the Employee  to the variable age.
   public void empAge(int empAge){
      age =  empAge;
   }
   /* Assign the designation to the variable designation.*/
   public void empDesignation(String empDesig){
      designation = empDesig;
   }
   /* Assign the salary to the variable	salary.*/
   public void empSalary(double empSalary){
      salary = empSalary;
   }
   /* Print the Employee details */
   public void printEmployee(){
      System.out.println("Name:"+ name );
      System.out.println("Age:" + age );
      System.out.println("Designation:" + designation );
      System.out.println("Salary:" + salary);
   }
}
</pre>
<p>As mentioned previously in this tutorial, processing starts from the main method. Therefore in-order for us to run this Employee class there should be main method and objects should be created. We will be creating a separate class for these tasks.</p>
<p>Given below is the <i>EmployeeTest</i> class, which creates two instances of the class Employee and invokes the methods for each object to assign values for each variable.</p>
<p>Save the following code in EmployeeTest.java file</p>
<pre class="prettyprint notranslate tryit" title="employee">
import java.io.*;

public class EmployeeTest{

   public static void main(String args[]){
      /* Create two objects using constructor */
      Employee empOne = new Employee("James Smith");
      Employee empTwo = new Employee("Mary Anne");

      // Invoking methods for each object created
      empOne.empAge(26);
      empOne.empDesignation("Senior Software Engineer");
      empOne.empSalary(1000);
      empOne.printEmployee();

      empTwo.empAge(21);
      empTwo.empDesignation("Software Engineer");
      empTwo.empSalary(500);
      empTwo.printEmployee();
   }
}
</pre>
<p>Now, compile both the classes and then run <i>EmployeeTest</i> to see the result as follows:</p>
<pre class="prettyprint notranslate">
C:\&gt; javac Employee.java
C:\&gt; javac EmployeeTest.java
C:\&gt; java EmployeeTest
Name:James Smith
Age:26
Designation:Senior Software Engineer
Salary:1000.0
Name:Mary Anne
Age:21
Designation:Software Engineer
Salary:500.0
</pre>
<h2>What is Next?</h2>
<p>Next session will discuss basic data types in Java and how they can be used when developing Java applications.</p>
<hr />
<div class="pre-btn">
<a href="/java/java_basic_syntax.htm"><i class="icon icon-arrow-circle-o-left big-font"></i> Previous Page</a>
</div>
<div class="print-btn center">
<a href="/cgi-bin/printpage.cgi" target="_blank"><i class="icon icon-print big-font"></i> Print</a>
</div>
<div class="pdf-btn">
<a href="/java/pdf/java_object_classes.pdf" title="Java - Object &amp; Classes" target="_blank"><i class="icon icon-file-pdf-o big-font"></i> PDF</a>
</div>
<div class="nxt-btn">
<a href="/java/java_basic_datatypes.htm">Next Page <i class="icon icon-arrow-circle-o-right big-font"></i>&nbsp;</a>
</div>
<hr />
<!-- PRINTING ENDS HERE -->
<div class="bottomgooglead">
<div class="bottomadtag">Advertisements</div>
<script type="text/javascript"><!--
var width = 580;
var height = 400;
var format = "580x400_as";
if( window.innerWidth < 468 ){
   width = 300;
   height = 250;
   format = "300x250_as";
}
google_ad_client = "pub-7133395778201029";
google_ad_width = width;
google_ad_height = height;
google_ad_format = format;
google_ad_type = "image";
google_ad_channel ="";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3" id="rightbar">
<div class="simple-ad">
<a href="javascript:void(0)" onclick="var sTop = window.screen.height/2-(218); var sLeft = window.screen.width/2-(313);window.open('http://www.facebook.com/sharer.php?u=' + 'http://www.tutorialspoint.com/java/java_object_classes.htm','sharer','toolbar=0,status=0,width=626,height=456,top='+sTop+',left='+sLeft);return false;">
<img src="/images/facebookIcon.jpg" alt="img" />
</a>
<a  href="javascript:void(0)" onclick="var sTop = window.screen.height/2-(218); var sLeft = window.screen.width/2-(313);window.open('http://twitter.com/share?url=' + 'http://www.tutorialspoint.com/java/java_object_classes.htm','sharer','toolbar=0,status=0,width=626,height=456,top='+sTop+',left='+sLeft);return false;">
<img src="/images/twitterIcon.jpg" alt="img" />
</a>
<a  href="javascript:void(0)" onclick="var sTop = window.screen.height/2-(218); var sLeft = window.screen.width/2-(313);window.open('https://www.linkedin.com/cws/share?url=' + 'http://www.tutorialspoint.com/java/java_object_classes.htm&amp;title='+ document.title,'sharer','toolbar=0,status=0,width=626,height=456,top='+sTop+',left='+sLeft);return false;">
<img src="/images/linkedinIcon.jpg" alt="img" />
</a>
<a  href="javascript:void(0)" onclick="var sTop = window.screen.height/2-(218); var sLeft = window.screen.width/2-(313);window.open('https://plus.google.com/share?url=http://www.tutorialspoint.com/java/java_object_classes.htm','sharer','toolbar=0,status=0,width=626,height=456,top='+sTop+',left='+sLeft);return false;">
<img src="/images/googlePlusIcon.jpg" alt="img" />
</a>
<a  href="javascript:void(0)" onclick="var sTop = window.screen.height/2-(218); var sLeft = window.screen.width/2-(313);window.open('http://www.stumbleupon.com/submit?url=http://www.tutorialspoint.com/java/java_object_classes.htm&amp;title='+ document.title,'sharer','toolbar=0,status=0,width=626,height=456,top='+sTop+',left='+sLeft);return false;">
<img src="/images/StumbleUponIcon.jpg" alt="img" />
</a>
<a  href="javascript:void(0)" onclick="var sTop = window.screen.height/2-(218); var sLeft = window.screen.width/2-(313);window.open('http://reddit.com/submit?url=http://www.tutorialspoint.com/java/java_object_classes.htm&amp;title='+ document.title,'sharer','toolbar=0,status=0,width=626,height=656,top='+sTop+',left='+sLeft);return false;">
<img src="/images/reddit.jpg" alt="img" />
</a>
</div>
<div class="rightgooglead">
<script type="text/javascript"><!--
google_ad_client = "pub-7133395778201029";
google_ad_width = 300;
google_ad_height = 250;
google_ad_format = "300x250_as";
google_ad_type = "image";
google_ad_channel ="";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<div class="rightgooglead">
<script type="text/javascript"><!--
google_ad_client = "pub-7133395778201029";
google_ad_width = 300;
google_ad_height = 600;
google_ad_format = "300x600_as";
google_ad_type = "image";
google_ad_channel ="";
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<div class="rightgooglead">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-2537027957187252";
/* Right Side Ad */
google_ad_slot = "right_side_ad";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="//pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</div>
</div>
</div>
</div>
</div>

<div class="footer-copyright">
<div class="container">
<div class="row">
<div class="col-md-1">
<a href="index.htm" class="logo"> <img alt="Tutorials Point" class="img-responsive" src="/scripts/img/logo-footer.png"> </a>
</div>
<div class="col-md-4 col-sm-12 col-xs-12">
   <nav id="sub-menu">
      <ul>
         <li><a href="/about/tutorials_writing.htm">Write for us</a></li>
         <li><a href="/about/faq.htm">FAQ's</a></li>
         <li><a href="/about/about_helping.htm">Helping</a></li>
         <li><a href="/about/contact_us.htm">Contact</a></li>
      </ul>
   </nav>
</div>
<div class="col-md-3 col-sm-12 col-xs-12">
<p>&copy; Copyright 2015. All Rights Reserved.</p>
</div>
<div class="col-md-4 col-sm-12 col-xs-12">
   <div class="news-group">
      <input type="text" class="form-control-foot search" name="textemail" id="textemail" autocomplete="off" placeholder="Enter email for newsletter" onfocus="if (this.value == 'Enter email for newsletter...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Enter email for newsletter...';}">
      <span class="input-group-btn"> <button class="btn btn-default btn-footer" id="btnemail" type="submit" onclick="javascript:void(0);">go</button> </span>
      <div id="newsresponse"></div>
   </div>
</div>
</div>
</div>
</div>
</div>
<!-- Libs -->
<script type="text/javascript" src="/theme/js/custom-min.js"></script>
<script src="http://www.google-analytics.com/urchin.js">
</script>
<script type="text/javascript">
_uacct = "UA-232293-6";
urchinTracker();
$('.pg-icon').click(function(){
   $('.wrapLoader').show();
});
</script>
<script type="text/javascript" src="/theme/js/jquery.colorbox-min.js"></script>
<script type="text/javascript">
   var tryit = new $.TryIt('java/try_java.php');
   tryit.compile();
</script></div>
</body>
</html>

download  show line numbers   

Snippet is not live.

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #3000030
Snippet name: Contents of http://www.tutorialspoint.com/java/java_object_classes.htm
Eternal ID of this version: #3000030/1
Text MD5: 356ccfd374e4e286b04710d37c8f08b2
Author: someone
Category:
Type: New Tinybrain snippet
Gummipassword: url-loader
Uploaded from IP: 176.0.118.225
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-30 18:09:01
Source code size: 31050 bytes / 611 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 2220 / 989
Referenced in: [show references]