Tutorials for Core Java beginners

Tutorials for Core Java beginners

Can anyone share their example of Encapsulation in java? I'm a core Java beginner.

View Answers

February 24, 2008 at 7:15 PM

Hi,

Here is the description of Encapsulation in java:

Encapsulation is a process of binding or wrapping the data and the codes that operates on the data into a single entity. This keeps the data safe from outside interface and misuse. One way to think about encapsulation is as a protective wrapper that prevents code and data from being arbitrarily accessed by other code defined outside the wrapper.

In other words, encapsulation is the ability of an object to be a container (or capsule) for related properties (ie. data variables) and methods (ie. functions).


public class Box
{
// what are the properties or fields
private int length;
private int width;
private int height;

// what are the actions or methods
public void setLength(int p)
{length = p;}

public void setWidth(int p)
{width = p;}

public void setHeight(int p)
{height = p;}

public int displayVolume()
{System.out.println(length*width*height)...
}

public static void main(String args [ ])
{
Box b1=new Box(3,4,5);
b1.displayvolume();
}


Thanks









Related Tutorials/Questions & Answers:
Good tutorials for beginners in Java
Good tutorials for beginners in Java   Hi, I am beginners in Java... in details about good tutorials for beginners in Java with example? Thanks.   ... the various beginners tutorials related to Java http://www.roseindia.net/java/beginners
tutorials - Java Beginners
tutorials  may i get tutorials for imaging or image processing in java  Hi friend, Please explain problem in details what you want with image in java. Thanks
Advertisements
Which is the best Java tutorials for beginners?
Which is the best Java tutorials for beginners?  Hello, I am trying to find good tutorials for beginners. Which is the best Java tutorials... Tutorial for Beginners. This tutorial is best for learning Java. Beginners
Java programming for beginners video tutorials
Java programming for beginners video tutorials  Hi, I am trying to find the Java programming for beginners video tutorials. Let's know the url... for Java beginners. All the tutorials contains free examples. Thanks
Java Video Tutorials for beginners
Java Video Tutorials for beginners are being provided at Roseindia online for free. These video tutorials are prepared by some of the best minds of Java... websites.ADS_TO_REPLACE_2 Java video tutorials for beginners are divided
Java Programming Tutorials for beginners
Java Programming tutorials for beginners are made in such a way... for beginners Java tutorials for beginners with examples Java tutorials for beginners using eclipse Complete Java programming tutorials for beginners
Java tutorials for beginners with examples
Java Video tutorials with examples are being provided to help the beginners... and easiest way is to learn Java online. At Roseindia Java tutorials and Java... in practical implementation. If you are wondering why Java tutorials, it is because
Learn PHP Tutorials for Beginners
Learn PHP Tutorials for Beginners  Hi, I am just pass-out from college and eager to learn the PHP. Can anyone suggest or provide me a resourceful information for php beginners. Thanks
Complete Java programming tutorials for beginners
Complete collection of Java programming tutorials for beginners is available... programming. These programming tutorials have a vast collection of Java... programming is through online Java tutorials. The first benefit is that it is free
j2me tutorials - Java Beginners
Core Java tutorial for beginners
Core Java tutorials for beginners makes its simpler for novices... that programmer will find useful in learning the language. Each Core Java tutorials... is a list of the few Core Java tutorials, examples and programs that can help you
java tutorials
java tutorials  Hi, Much appreciated response. i am looking for the links of java tutorials which describes both core and advanced java concepts... one stop material which discusses each and every concept of core and advanced
core java - Java Beginners
core java  i want to get java projects in core java
core java - Java Beginners
Core Java interview Help   Core Java interview questions with answers  Hi friend,Read for more information.http://roseindia.net/interviewquestions
JAVA(core) - Java Beginners
JAVA(core)  Core Java  In java 'null' is keyword which means object have nothing to store. even not allocated memory
core Java - Java Beginners
core Java  how is it possible to create object before calling main() in Java
Core Java - Java Beginners
Core Java  What is Java? I am looking for Core Java Training  Hi friendThe Core Java Technologies and application programming interface... Microsystems. We generally introduce java in two ways, core java and advance java
Core Java - Java Beginners
://www.roseindia.net/software-tutorials/detail/10992 visit www.roseindia.net/java...Core Java  Can u give real life and real time examples of abstraction, Encapsulation,Polymarphism....?  I guess you are new to java and new
core java - Java Beginners
core java  what is object serialization ? with an example   Hi Friend, Please visit the following link: http://www.roseindia.net/java/example/java/io/SerializingObject.shtml Thanks
core java - Java Beginners
core java  hallo sir, in java ,int range is -128 to 127. what about '0' indicate what  Hi, In java byte range is -128 to 127, not of int
core java - Java Beginners
core java   what is the difference b/w #include and import??  Hi Friend, Do you want the difference b/w '#include in C' and 'import in java'? Thanks
core java - Java Beginners
core java  what is thread ? i can't understand it's need?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/thread/ Hope that it will be helpful for you. Thanks
core java - Java Beginners
core java  how many keywords are in java? give with category? .../java/language/java-keywords.shtml http://www.roseindia.net/java/master-java/java-keywords.shtml Thanks
core java - Java Beginners
core java  how to write a simple java program?  Hi friend..."); } } ------------------------------------------- Read for more information. http://www.roseindia.net/java/master-java/index.shtml Thanks
core java - Java Beginners
core java  Can we provide more than 1 try catch block  Hi Friend, Yes you can. For more information, please visit the following link: http://www.roseindia.net/java/exceptions/nested-try.shtml Thanks
core java - Java Beginners
core java  when write java program in editplus.then save&compile the file. 1-text file 2-class file 3-bak file how can get this files plz tell me  Hi Friend, Please clarify your problem. Thanks
core java - Java Beginners
core java  what are the type of scope variables and use
core java - Java Beginners
core java  can we write a program for adding two numbers without...-in-java/ it's about calculating two numbers Java Program Code for calculating two numbers http://www.roseindia.net/java/java-conversion/calculating-three
Core java - Java Beginners
Core java  Hello sir/madam, Can you please tell me why multiple inheritance from java is removed.. with any example.. Thank you...://www.roseindia.net/java/master-java/inheritance.shtml Thanks  Hi
core java - Java Beginners
core java  can we define a function in java and answer is yes, then how we define a function in java pls provide code?  Hi Friend, class Numbers{ public int add(int num1,int num2) { return num1+num2
core java - Java Beginners
core java  hi.. one probledm from my end how we can perform the TaskSheduling in java ? coming to my project: Its is NMS domain My project is to collect Data from network and store the data in a FileSystem and after
core java - Java Beginners
core java  write a program to display equilateral traiangle using stars? output will be as follows: * * * * * * * * * * ...://www.roseindia.net/java/ Thanks
core java - Java Beginners
core java  Diff b/w Throws and Throw  Hi Friend, Please visit the following link: http://www.roseindia.net/java/exceptions/how-to-throw-exceptions.shtml Thanks  throw is used for throwing exceptions
core java - Java Beginners
core java  hi, what is the difference between method... and Overriding: http://www.roseindia.net/java/javascript-array/modified-java-method-overloading.shtml http://www.roseindia.net/java/javascript-array/modified-java
core java - Java Beginners
core java  When we will use marker interface in our application?  Hi friend, Marker Interface : In java language programming...://www.roseindia.net/java/master-java/interface.shtml Thanks
core java - Java Beginners
core java  What is the difference between interfaces and classes?  Hi friend, ABSTRACT CLASS Interface... information : http://www.roseindia.net/help/java/a/interface-vs-abstract
core java - Java Beginners
core java  catch(Exception e) { System.out.println(e); } what is use of this??  Hi Friend, The catch block is used as an exception... the following link: http://www.roseindia.net/java/exceptions/catching-and-handling
core java - Java Beginners
core java   How to reverse the words in a given [email protected]  Hi friend, import java.io.*; public class...); } } ------------------------------------------------------- Read for more information. http://www.roseindia.net/java/ Thanks
core java - Java Beginners
core java  write a program to add two numbers using bitwise operators?  Hi friend, i am sending running code. public class...://www.roseindia.net/java/ Thnaks. Amardeep
Core Java - Java Beginners
Core Java  How can I take input?  hai.... u can take input through command line or by using buffered reader. An wexample for by using... information : http://www.roseindia.net/java/ Thanks
core java - Java Beginners
core java  Hi guys, String class implements which interface plzzzzzzzzzzzzz can any body tell me its very very urgentttttttttttttttt Thanks  String implements the Serializable, CharSequence
core java - Java Beginners
core java  Hi Friends, If in an application only one thread is there if i will use wait() method what will happened ????????????????any error will come ya that wait() method will work plzzzzzzzzzzzzzzzzzzzzzz tell me
Core Java - Java Beginners
Core Java  How can we explain about an object to an interviewer  Hi friend, Object : Object is the basic entity of object oriented... to : http://www.roseindia.net/java/master-java/java-object-oriented
core java - Java Beginners
core java  1. What are the Advantages of Java? 2. What are the Differences between c,c++ & java? 3. Where we need to Write Java Programs? 4... the following link: http://www.roseindia.net/java/java-introduction/java
core java - Java Beginners
core java  "Helo man&sir can you share or gave me a java code hope its ok?"thank you Design a program that records and reports the weekly sales.... core java jsp servlet Friend use Core JAVA .thank you so much.hope you
Core Java - Java Beginners
Core Java  Hi Sir/Madam, Can u please explain about the Double in java. I have problem with Double datatype. public class DoubleTesting { public static void main(String[] args) { Double amt=137.17*100
core java - Java Beginners
core java   sir why did u declare or intilize the variables in static main method().. But non-static members are does't decalred in the static function?? we only declare the static members in static function only
core java - Java Beginners
core java  Hi, if two interfaces having same method can that method will override i mean can we override methods in interface.plzzzzzzzzzzz can any body help me plzzzzzzzzzzzzzzzzzz...   Hi
core java - Java Beginners
core java  public static void main(String[] args) why are write only string[].. why cann't write int,float   Hi Friend, Because it is very easy to convert string to other data type. Thanks
core java - Java Beginners
core java  how to create a login page using only corejava(not servlets,jsp,hibernate,springs,structs)and that created loginpage contains database(ms-access) the database contains data what ever u r enter and automatically date

Ads