Why is encapsulation called wrapping?
Encapsulation is also known as wrapping because it wraps the data in the same way as a toffee is wrapped to create a logical insulation between the data(program) & the outer world(computer).
Java applet program to draw national flag?
import java.io.*;
import java.applet.*;
import java.awt.*;
public class flag extends Applet
{
public void paint(Graphics g)
{
g.fillOval(60,450,120,50);
g.fillRect(110,60,10,400);
g.setColor(Color.red);
g.fillRect(120,80,150,30);
g.setColor(Color.white);
g.fillRect(120,110,150,30);
g.setColor(Color.green);
g.fillRect(120,140,150,30);
g.setColor(Color.black);
g.drawRect(120,80,150,90);
g.setColor(Color.blue);
g.drawOval(180,110,30,30);
int t=0;
int x=195,y=125;
double x1,y1;
double r=15;
double d;
for(int i=1;i<=24;i++)
{
d=(double)t*3.14/180.0;
x1=x+(double)r*Math.cos(d);
y1=y+(double)r*Math.sin(d);
g.drawLine(x,y,(int)x1,(int)y1);
t+=360/24;
}
}
}
What are the operation performed by MPU?
The basic operations performed by MPU are under as follows:
(1)Memory Read
(2)Memory Write
(3)Input/Output Read
(4)Input/Output Write
Can you access a protected member from a Sub class outside the package of its Base class?
Protected members of a class are only accessible to its subclasses and to friends of the class or its subclasses. However, if a subclass changes the access to private, only the subclass and its friends have access but this does not affect the access rights of its ancestors or their friends.
Why do modern machines consist of multiple levels of virtual machines?
Modern machines do not consist of multiple levels of virtual machines; that is a function of the host operating system's virtual machine manager and its guest operating systems, all of which are implemented through software. The operating system's virtual machine manager exposes one or more virtual machines upon which you can host one or more guest operating systems and their applications. In order to execute compiled Java applications upon one of these guest operating systems you will also need to install the Java virtual machine for that specific operating system. Thus you end up with a Java program executing within a Java virtual machine executing within a virtual machine executing within a virtual machine manager executing upon the physical hardware. The physical hardware itself may be optimised to handle virtual machine managers more efficiently, but the virtual machine manager is a software program; it is not part of the physical machine architecture
:: A set of instructions transferred between an artist in the audience::Apex
What are importance of algorithm?
Algorithms are the foundation of computer Science, it is telling the computer to do the task in the most efficient matter. An algorithm is particularly important in optimizing a computer program, the efficiency of the algorithm usually determines the efficiency of the program as a whole.
What does the assert keyword do in Java?
assert is a keyword added in Java version 1.4.
assert tests the programmer's assumption during development without writing exception handlers for an exception. Suppose you assumed that a number passed into a method will always be positive. While testing and debugging, you want to validate your assumption. Without the assert keyword, you will write a method like:
private void method(int a) {
if (a >= 0) {
// do something that depends on a not being negative
} else {
// tell the user that a is negative
}
}
This is simple exception handling; consider the case of big one. Assertion will come into the picture when you don't want to take the time to write the exception handling code.
Consider the above program with assertion:
private void method(int a) {
assert (a>=0); //throws an assertion error if a is negative.
// do stuff, knowing that a is not negative
}
In this program, assert (a>0) will pass when 'a' is only positive. Isn't this much cleaner than the previous example? If the value of 'a' is negative, then an AssertionError will be thrown.
There are two types of assertions:
Example of a really simple assertion:
private void method() {
assert (x>0);
//do more stuff
}
Example for simple assertion:
private void method() {
assert (x>0) : "X is" + x ;
// do more stuff
}
The difference between these two is that the simple assertion - the second example - appends the expression after the colon to the error description in the stack trace.
Note: assertion code - in effect - evaporates when the program is deployed.
For assertion first you need to invoke the assertion.
Asserts are disabled by default in the JVM. In order to run a program with asserts you must use the -ea command line parameter (i.e. java -ea AssertTest).
Even though your compiler suggested it was using java version 1.4, it wasn't actually because you compiled using the "javac [files]" command instead of the "javac -source 1.4 [files]" command. Assertions only work in version 1.4 and later versions.
When you are using assert keyword, you have to enable it. Otherwise it wont give any result.
java -enableassertions classfile
Difference between super and final keyword?
this is a reference to the current class
super is a reference to the super class of the current class (the class from which this class extends). You can use super.super if you want to access the second level class. (The class your parent class extends) The purpose of having thisand super keywords is to differentiate between methods and variables in classes that may have the same name as that in the parent class. Under such situations if we want to ensure that only the methods from a particular class only gets called we can use this and super.
Which OS does not support JAVA?
This is hard to say with any certainty, since there are very many operating systems out there. Most of those operating systems don't have a large enough user/developer base to warrant an implementation of Java.
Officially, Sun only offers downloads for: Linux, Solaris, Windows, and (via Software Update) OS X.
Of course, Sun isn't the only group allowed to implement Java, which makes answering this question all that much more difficult.
IBM, for example, also supports z/OS and AIX (as well as Windows and Linux again).
BufferedWriter is the class which has a method called newLine() which actually writes a platform specific new line character and this method is not there in FileWriter class
super economy class is a mid-ranged product between economy and business class. it was designed to give you a better flight for around the price of economy. super economy offers better features such as extra legroom, seats are wider and there is more seat recline. the meal and beverage service, however, is the same or very similar to that served in economy class.
the super economy class was introduced because air travel companies were hard up and needed something to increase their profits and give them more customers. this provided both although only in America, Europe and Scandinavia. however some airlines have deigned this new style of flight as costly and unneccesary and have abolished it within their companies and stuck to economy. there are several opinions on the new sysytem and all of them have a degree of credibility. the fact, is that super economy will only work with the airlines that market it right.
take care of the data types of variables declared and format specifiers
What will heppen if an image drawn out of the window coordinate in Java?
ACM Java graphics programs run in a window called the graphics window. If the location is outside of the graphics window then the object is not visible.
What is the difference between the muffin method and the biscuit method?
in the muffin method you include the fat with the liquids , in the biscuit method you cut the fat (cold) into the dry ingredients. Also, in the biscuit method, you have to knead the dough, roll it and cut it
What does the final keyword mean in front of a variable a method a class?
When used in a class declaration, the final keyword means the a class can't be subclassed. In other words, no other class can extend (inherit) a final class, and any attempts to do so will give you a compiler error.
The final keyword prevents a method from being overridden in a subclass. Final methods are usually placed in classes where you don't want anyone who is extending your code to meddle with a certain piece of functionality.
Declaring a variable with the final keyword makes it impossible to reassign a different value to that variable once it has been initialized with an explicit value -
Is there a Pa Inheritance tax If so how much is it?
Pennsylvania is one of the Seven states who impose an inheritance tax on the property and belongings acquired. The tax rate varies from class to class. Class A benificiaries are to pay 4.5%, while Class A1 are subject to 12% and Class B to 15%.
What is package in oop object oriented programming?
A package is basically a group of related classes.
What is the full form of oak in java?
Oak was a programming language created by James Gosling in 1991, initially for Sun Microsystems set-top box project. The language later evolved to become Java.
The name Oak was used by Gosling after an oak tree that stood outside his office.