码迷,mamicode.com
首页 > 编程语言 > 详细

Java Class/Method

时间:2016-06-26 21:04:50      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:

  • A class can have only public or default(no modifier) access specifier.
  • It can be either abstract, final or concrete (normal class).
  • It must have the class keyword, and class must be followed by a legal identifier.
  • It may optionally extend one parent class. By default, it will extend java.lang.Object.
  • It may optionally implement any number of comma-separated interfaces.
  • The class‘s variables and methods are declared within a set of curly braces {}.
  • Each .java source file may contain only one public class. A source file may contain any number of default visible classes.
  • Finally, the source file name must match the public class name and it must have a .java suffix.

 

 How a class is initialized in java

class is initialized in Java when an instance of class is created using either new operator or using reflection using

class.forName(). A class is also said to be initialized when a static method of Class is invoked or a static filed is assigned

 

 How to make a copy of an entire Java object with its state

Make that class implement Cloneable interface and call clone() method on its object.clone() method is defined in Object class which is the parent of all java class by default.

 

Java Method:

In java when you pass a primitive type to a method it is pass by value

when you pass an object of any type to a method it is passed as reference

 

Java Class/Method

标签:

原文地址:http://www.cnblogs.com/morningdew/p/5618525.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!