Submitted by: Submitted by YaraJ
Views: 10
Words: 1413
Pages: 6
Category: Other Topics
Date Submitted: 06/21/2016 01:42 PM
1. Explain about the following:
1. Encapsulation:
* Is the mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse.
* It is a protective wrapper that prevents the code and the data from being arbitrarily accessed by other code defined outside the wrapper.
2. Inheritance.
* Is the process by which one object acquires the properties of another object.
* The inheritance makes it possible for one object to be a specific instance of a more general case.
3. Polymorphism.
* Is a feature that allows one interface to be used for a general class of actions.
* Described by the phrase “One interface, multiple methods”
* This means it is possible to design a generic interface to a group of related activities.
2. Discuss in details about the primitive data types of Java with examples.
Java defines 8 primitive types of Data:
4. Byte: The smallest integer type is byte. This is a signed 8-bit type
The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters.
5. Short: is a signed 16-bit type. It is probably the least used java type.
6. Int: the most commonly used integer type is int. it is a signed 32-bit type.
7. Long: is a signed 64-bit type and is useful for those occasions where an int type is not large enough to hold the desired value.
8. Float: the type float specifies a single-precision value that uses 32 bits of storage.
9. Double: double precision, as denoted by the double keyword, uses 64 bits to store value.
10. Char: In Java, the data type used to store characters is char.
11. Boolean: Java has a primitive type, called Boolean, for logical values. It can have only two possible values, true or false.
3. What is the output of the following program.
Public class Scope
{
public static void main(String args[])
{
int x=10;
if(x==10)
{
int y=20;...