How java achieve architecture neutral?
"Architecture neutral" means that programs written in Java will run on different architectures, or platforms. That is, they will run on different processors (which may use different machine language), as well as on different operating systems.
Write a program in java to print amount of cable bill?
import java.io.*;
class Shop
{
String code[]=new String[20];
String name[]=new String[20];
float price[]=new float[20];
int i,j;
Shop()
{
i=0;
}
void getitem() throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter ItemCode:");
code[i]=br.readLine();
System.out.println("Enter ItemName:");
code[i]=br.readLine();
System.out.println("Enter UnitPrice:");
price[i]=Float.valueOf(br.readLine()).floatValue();
i++;
}
void printitem()
{
System.out.println("\n ItemCode\tItemName\tunitPrice\n");
for(j=0;j<i;j++)
{
System.out.println(code[j]+"\t\t");
System.out.println(name[j]+"\t\t");
System.out.println(price[j]+"\t\t");
}
}
}
class ShopOnl
{
public static void main(String args[]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int ch=0;
Shop s=new Shop();
while(ch!=3)
{
System.out.println("1.Get Item");
System.out.println("2.View Bill");
System.out.println("3.Quit");
System.out.println("Enter your choice");
ch=Integer.parseInt(br.readLine());
switch(ch)
{
case 1:
s.getitem();
break;
case 2:
s.printitem();
break;
case 3:
System.out.println("Thank you! visit again");
break;
}
}
}
}
Can int value be assigned to char variable?
Yes, but the results may not be what you expect, depending on the relative sizes of an int and a char (in bytes), whether they are signed or unsigned, and whether they use big-endian notation or not.
By way of an example, in C++ an int is typically 4 bytes long while a char is 1 byte long. Both are signed by default. If you were to loop an integer from 0x80000000 to 0x7fffffff (-2147483648 to +2147483647) using big-endian notation and assign the value to a signed char, then the char would repeatedly cycle through the values 0 to 127, then -128 to 0. This is because the char takes on the value of the least-significant byte of the integer in big-endien notation (the bytes are effectively reversed in memory). However, if you cycle the int from 0xffffff80 to 0x7f (-128 to +127), then you get the expected behaviour (the char cycles from -128 to +127). However, if the char were unsigned, then the first loop would repeatedly cycle from 0 to 255 while the second would cycle from 128 to 255, and then from 0 to 127.
Thus to get the expected behaviour, both the int and char must both be signed or both must be unsigned, and the range of values must be within the range of the smaller of the two types (which will typically be the char), and the system must either use big-endian notation (reverse notation) or must otherwise compensate for little-endian notation.
Write a simple Java program to convert rupees to dollars?
import java.util.Scanner;
public class rupeesconversion {
public static void main(float[] args) {
//Have the user to enter rupees
System.out.println("Enter rupees");
double rupees_r;
//Convert rupees to dollars.
if (rupees_r>1) {
double dollar = ruppes_r/45.2;
System.out.println("the converted value from rupees to dollars is:"dollar);
}
else
System.out.println("Try again");
}
}
What is the point that is the same distance from any circle?
There is such a point only if all the circles are concentric.
Explain the structure of a java program?
The fundamental structure of any Java programme should look like:
[package declarations]
[import statements]
[class declaration]
An example is given below:
package abc;
import java.lang;
class Demo {
public static void main(String[] args) {
Sytem.out.println("Hello! World");
}
}
//The file containing this class must be named Demo.java
What is an Program compilation?
That means to convert the original program - the source code, written by a programmer - into machine language, or into an intermediate form, for example, Java bytecode in the case of Java.
That means to convert the original program - the source code, written by a programmer - into machine language, or into an intermediate form, for example, Java bytecode in the case of Java.
That means to convert the original program - the source code, written by a programmer - into machine language, or into an intermediate form, for example, Java bytecode in the case of Java.
That means to convert the original program - the source code, written by a programmer - into machine language, or into an intermediate form, for example, Java bytecode in the case of Java.
Why cup symbol is used for java?
I read this in a book that it's because all class files in Java are identified by a magic number which reads CAFEBABE in hexadecimal assembly. The software engineers that designed Java at Sun used to take a break in a nearby cafe during work hours where they checked out hot girls while sipping their coffee.
What is java primitive data types?
Any data that is not stored as an object - like the integral data types (int, long, etc.), or boolean variables.
Any data that is not stored as an object - like the integral data types (int, long, etc.), or boolean variables.
Any data that is not stored as an object - like the integral data types (int, long, etc.), or boolean variables.
Any data that is not stored as an object - like the integral data types (int, long, etc.), or boolean variables.
How do you edit java applications?
You can use any text editor, like NotePad. Although normally, it is easier to use some IDE for Java programming; those IDEs have a built-in editor.
Difference between encapsulation and abstraction?
Encapsulation means hiding something, so you don't know anything about it, not even whether it exists or not.
Abstraction means vague, you may know what it is or expect what it will be and thus behave, but not exactly. And you don't know how it (the object) is implemented in details.
In a more compact context, encapsulation is referring to hiding data members (or attributes) and their types from outsiders, while abstraction means to define the interface or behaviors of an object (the APIs). You know the method signatures (the contracts), but you don't know anything about the implementation.
lavatron is a sport arena light bulb display.it is a kind of applet.it is invented by david la velle.lavatron is able to produce the on screen image nd its Sid effects allow it to load very quickly.
What is the difference between AP classes and Advanced Classes in high school?
Gifted classes are for those who either have certain conditions that need to be met or are considered quite smart for their age.
AP, or advanced placement, classes are more or less classes preparing you for an advanced level of work. AP Calculus or AP Biology prepare you for college and have the chance to give you credit for the courses, this way you won't have to take them during your enrollment in college.
What is compilation process in programming?
In general a compiler will go through a few steps:
# Lexical analysis - making sure all the symbols in the source code are legal, and turning them into "tokens" for the next step.
# Syntactic analysis - analyze the tokens, ensuring they follow the rules of the language grammar and parsing them into some form of syntax tree. # Code generation - uses the syntax tree to create some form of intermediate language; oftentimes into assembly instructions, or a unique assembly-like language. # Code optimization - may or may not perform optimization on the intermediate language before translating it into executable code. Of course the true process of compilation is almost always much more complex than this, and may involve many more steps.
How do you compile applet programs in java?
1. first you type your applet programm in notepad in save it as classname.java in the bin directory. example: if the class name is A then save it in jdk1.5->bin as A.java
2. now create a HTML file in notepad as given below
and save it as in bin by A.HTML
NOTE: applet code should be always classname.java and also save with same classname.HTML
3. now go to strart->run type cmd press enter the dos screen will open.
4. give the location where you saved the file as
D: CD jdk1.5 press enter
CD bin enter
javac A.java
appletviewer A.HTML
What is the Fahrenheit to Celsius program in java?
degreesFahrenheit = degreesCelsius * 9 / 5 + 32;
degreesFahrenheit = degreesCelsius * 9 / 5 + 32;
degreesFahrenheit = degreesCelsius * 9 / 5 + 32;
degreesFahrenheit = degreesCelsius * 9 / 5 + 32;
How do you write simple java program to print equlater star pyramid?
public class StarPyramid
{
public static void main(String [] args)
{
int space = 0, line = 0, star = 0;
for(line = 1; line <= 26; line ++)
{
for(space = 26; space > line; space--)
{
System.out.print(" "); // Display one space
}
for(star = 1; star < line; star++)
{
System.out.print("*‟);
}
for(star = line; star >= 1; star--)
{
System.out.print("*‟);
}
System.out.println(); // Display new line with ln
}
}
}
What are the advantage of database?
In every field of work there is a need of maintaining database to store records . The major advantages of the DBMS are the speed , flexibility, ease , and that it can be stored anywhere. Also the data is very consistent and integrated.
What is the Java program to print the following pattern 1 234 56789 101112 13?
import java.io.*;
class pattern
{
void main() throws IOException
{
int i,j;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter n terms");
i=Integer.parseInt(br.readLine());
for(i=1;i<=4;i++)
{
for(j=1;j<=i;j++)
{
System.out.print(j);
}
System.out.println();
}
}
}
What is the language primarily used for Internet based applications?
with single programming language we cannot do anything on the internet. Actually every application in java is divided into three layers. Presentation layer, Application layer, Data layer. Every layer has its own specification. Presentation layer role is to interact with client means presentation layer takes input from the user and send it to Application layer. Application layer is a business logic layer. All the logic is done in this layer. Data layer contains the data.
for example:- suppose user enters student no. and student name in presentation layer, from here the data is send to application layer. In application layer we can write the logic for inserting, deleting, retriving and modifying the user data in database. From here the controller goes to datalayer to fetch data from database and sends the data back to user then the user see the corresponding data in the presentation layer.
For presentation layer: html, jsp, velocity etc are used.
For application layer: ejb, hibernate.......
for data layer: oracle.......
How data hiding is achieved in java?
Data hiding in the java is achieved through the use of encapsulation.
What is the scope of any variable?
The Scope of a variable defines the areas of a program where this variable would be visible and can be used. For ex:
a. Method variables - are visible only inside the method where they are declared and hence their scope is only the method
b. Class variables - are visible inside the class and can be used by any method inside the class and hence their scope is the whole class.
If it is already compiled, you can start your Java program from the command line. Just type
java myclass
replacing "myclass" with the program you want to start - a program with the ".class" extension, for example, myclass.class.
Difference between fixed loop and variable loop?
Fixed loop: this is the loop where the number of iterations are known.
Variable loop: Here the number of iterations are not known
Example for a variable loop.
The pseudocode for variable whille loop
begin
character cchoice
display"enter the choice"
accept cchoice
while(cchoice='y')
begin
//execute the statements
end
end
Rkarthikeyan