Unanswered | Answered

Java Programming

Parent Category: Computer Programming
The Java programming language was released in 1995 as a core component of the Java platform of Sun Microsystems. It is a general-purpose, class-based, object-oriented language that is widely used in application software and web applications.
Toll Free :0800-098-8906. For BT Yahoo - United Kingdom. Is thisthe right phone number?
// set up reader BufferedReader reader = new BufferedReader(new InputStreamReader( System.in)); // number of line to read int numberOfLines = 3; // initialize the counter for number of characters int numberOfChars = 0; // prompt user to enter the lines of text System.out.format("Enter %d lines of...
The data type for 0.38 is double.
To test whether Java is installed and enabled in Firefox, visit oneof these Java test pages: Verify Java Version Verify Java Version (alternate) When you visit these pages, you will normally need to activateJava. The article How to allowJava on trusted sites explains how.
Simply because, GUIs can be of any level of complexity. Elementssuch as buttons, links, etc all need to properly reference todifferent objects. If you click here, go there, if you click downthere, go here, etc. It is like a very big, complex web. You canimagine that procedural code would make it...
Data is stored as objects and can be interpreted only using themethods specified by its class.
can u please elaborate the question for details on database visit" tutorialsera "
A Java thread can be considered as similar to a user level thread. Let us say you are running a web browser, windows media player and GTalk for chat simultaneously - Actually the operating system is running an individual thread for each of these apps which gives you a seamless feeling of things...
I actually have the author of this book as one of my Computer Science Professors at Armstrong. The book is really well layed out and easy to understand, even for beginners! The book is: Introduction to Java Programming *Eigth Edition By: Y. Daniel Liang Here is his website, it has a list of all...
Here is a website with all kinds of java programming books: http://www.freeprogrammingbook.com/java.php
Multithreading: Multithreading is a process of executing multiple threadssimultaneously.. The concept of threads provides a mechanism to make maximumutilization of CPU.Basically a thread is a light weightprocess. . Both multithreading and multiprocessing are used to achievemultitasking.But...
The most common reason I have for catching Exceptions in Java is when reading information from a file. So let's look at an example where we read and display the contents of a file. // Note that the main method may throw a FileNotFoundException. // This means that if the file we try to read from...
Java has three types of comments that I know of... Single line comments beginning with a double forward obliquestroke: // This is a single line comment // here's another There's also multi-line comments: /* This comment could ** traverse ** many lines. It starts with a forward oblique stroke, **...
I bought a 1 ton split A\C this week. It's power consumption is1000 W. The outer temperature in our area in day time is 34-36degree Celsius. I set up the ac for a 27 degree which iscomfortable for me. So i want to know, how to reduce then powerconsumtion of this ac. My room is much smaller 10(w) X 8...
import java.io.*; class StateCap { protected static void main()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); String s[]={"Uttar Pradesh","Maharshtra","West Bengal","Bihar","Jharkhand","Kerala","Tamil Nadu","Madhya Pradesh","Sikkim",...
Runnable in java , is an interface which helps in creating threads. E.g. you want to create thread Demo , then you will do like this class Demo implement Runnable { // your code } Now to start thread in a program you have to do like this /* create your thread class object & then pass it to thread...
There are many way to define a term, one of which is: When a class inherits properties and behaviours of two more classesit is said to be multiple inheritance.
When all references to an object is Java are gone, the garbage collector will come along and free up the memory used by that object. Every Java object has a method named finalize , which is called by the garbage collector when the memory for that object is being deallocated. "Finalization" is...
The java.lang.System class contains several useful classfields and methods. It cannot be instantiated.Facilities providedby System: standard output error output streams standard input and access to externally defined properties andenvironment variables. A utility method for quickly...
final keyword when used with a variable makes it a constant whichmeans we cannot change it's value further: eg: final int MY_CONST = 30; // creating a constant with final keyword MY_CONST = 40;//this line will generate an error as MY_CONST is aconstant -------------------------------------- static...
Two-dimensional arrays are typically iterated through using nested for loops. If you had a 2-D array alpha with ints ROWS and COLS representing the number of rows and columns respectively, and ints row and col as iterators, the loop would look like this: for (row = 0; row < ROWS; row++){ for ...
import java.io.*; class AvgWordSent { protected static void main()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter the Sentence: "); String s=in.readLine(); byte a=0,b=0; float c=0; for(byte i=0;i
There is no difference. They mean exactly the same thing. Portable code is independent of the platform while non-portable code is platform-dependant.
To overcome the problems faced because of the use of structured programming, the object oriented programming concept was created. The OOP makes use of bottom-up approach and manages the increasing complexity. Description of an OOP can be given as , a data that controls access to code.
You can use Java Wrapper class to do this. You can use IntegerWrapper to create integer object and then use toString() to convertto String.
// This method will search through nums for target. // It will return the index of target in nums, or -1 if target is not in nums. public static int search(final int target, final int[] nums) { // Linear search means start at one end and search element-by-element for(int i = 0; i < nums...
There is not strict rule. It is only a convention. Most Javaprogrammers use camel case for methods and variables. All uppercaseare usually reserved for constants.
an object of the type you want is instantiated (created) by callingits constructor such as shown below: the "new" keyword is needed as it tells the compiler to create anew object of type MyClass. //creates an instance of a MyClass() Object MyClass() = new MyClass();
Remember that chars in Java are just a special version of ints. Cast the char as an int and you get the Unicode value for it. Fortunately, the group of characters including letters and numbers have the same value in both encoding systems. for (char letter = 'a'; letter
because java is categorized into packages and packages contain classes which are not accessible directly.
All Java methods belong to a class. This is just the way the language is designed. Besides, if any method were to be written outside of a class, you would have no way to reference it.
J2ME: java to micro edition for applications which run on resource constrained devices like cell phones. J2SE: java to standard edition and is normally for developing desktop applications.
A parameterized constructor allows the programmer who uses the object to pass parameters.\n\nFor example, without paramters, the creation of a point in 2-dimensional space might look like this (I am omitting the definition of the class; but you have to create the class as well):\n\n \nPoint...
Use a temporary variable. Example (swap variables "a" and "b"):\n\n \nint a = 5;\nint b = 10;\n\n// Swap the variables\nint temp;\ntemp = a;\na = b;\nb = temp;\nSystem.out.println("a = " + a);\nSystem.out.println("b = " + b);\n \n Use a temporary variable. Example (swap variables "a" and "b"):\n\n ...
boolean - 1 bit (1/8 bytes) - The actual storage requires for a boolean type is not defined for Java implementations. . byte - 1 byte . short - 2 bytes . int / char - 4 bytes . long - 8 bytes . float - 4 bytes . double - 8 bytes
int main() { int x, y; char op; int res; printf("Enter two numbers and a operator\n"); scanf("%d %d %c", &x, &y, &op); switch (op) { case '+': res = x+y; break; case '-': res = x-y; break; case '*': res = x*y; break; case '/': res = x/y; break; default: ...
Imagine you want to save the state of one or more objects. If Java didn't have serialization, you'd have to use one of the I/O classes to write out the state of the instance variables of all the objects you want to save. The worst part would be trying to reconstruct new objects that were virtually...
It is not. Visit java.sun.com and dowload the suitable JRE (or JDK) version for your platform. Note: The java bytecode executed by JVM is indeed platfom-independent.
No it can execute almost any byte code it is given not just Java
No you have to install it and it is platform dependent.
Casting an object to a child object is to make accessible fields,methods, etc that are found only in a child. For example. ObjectA has field apples, and ObjectB (which extends ObjectA) has field bananas, and ObjectC (which also extends ObjectA) has field strawberries. We created an instance of...
You cannot. Abstract classes cannot be instantiated and hence cannot be invoked from the main method or any other class directly.
Java does not support operator Overloading.
A static class may or may not have static members. Adding the static keyword to the class definition won't change this. Note that an inner class which is not static may not contain static members (unless those members are also declared final).
A constant is a term used in java whose values doesn't change during the execution of the program, while, a variable's value can be changed during the execution.
Scratch is an example of an object-oriented programming language.You can use it for free at scratch.mit.edu
"real" numbers, in any programming language, are actually approximations of what is called a "real number" in math. Basically, a number that can handle decimals - but unlike the actual real numbers, of limited precision. In Java, the "real" data types are float, and double. double has greater...
public class PrintValues { public static void main(String[] args) { for (int i = 1; i
It's easy to learn and works in browsers. Also, it was used to make Minecraft.
A BufferReader can read certain things like BufferedImage which with the right code can allow for animation to be done using a G.U.I (Graphical User Interface) if you want to see how its used i would recommend watching TheChernoProjects 3D game programming tutorials on youtube.
Java doesn't support multiple inheritance.
parseInt() is a method in the Integer class in Java that is used for parsing string values as numbers. int i = Integer.parseInt("10"); would result in i being assigned a value of 10
jdk 1.4 not hve for each regulear expression exception changing
import java.io.*; class sumo { protected static void main()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter the Number: "); int a=Integer.parseInt(in.readLine()),b=0; for(int i=a;i>0;i/=10) { int c=i%10; b+=c; ...
public int max(int x, int y, int z){return Math.max(x,Math.max(y,z));} . The method Math.max() only accepts 2 arguments, soyou need to perform this method twice if you want to compare 3numbers, as per the code above.
import java.io.*; class TwoD { protected static void main()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter the no. of Elements: "); byte a=Byte.parseByte(in.readLine()); int ar[]=new int[a]; long sum=0; for(byte...
A const data type is one which cannot be changed once initialized. A volatile data type is one which should never have its value locally cached. Note: Neither of them is data-type, they are modifiers.
/* INPUT: Holy Home * OUTPUT:H * ------------ o * --------------l * ---------------y * ---------------- _______________//The '-' are spaces * ------------------H * --------------------o * ---------------------m * -----------------------e * */ import java.io.*; class...
import java.io.*; class RevWords { private byte wo(String s) { byte a=0; for(byte i=0;i
it is java people community to discuss about the new development and new development those are done with java language it is presented
There are hundreds of pre-written libraries in java, which you canuse in your programs to make it easy to read and small. Matter offact you don't have to write big codes just import this library anduse their methods or class whatever you need. for example, you want use LinkedList in java. So instead...
When people say "primitive data types" they mean that the types cannot be divided even in simpler data types. For instance, type int describes all integer numbers and there is no mathematical point to split it in positive and negative. If you want to do so you need to use signed unsigned types...
1. It's easy to write unreadable code with it. 2. Some people's religion doesn't allow it. 3. There are languages that do not have goto.
Private variables (and methods) in Java are those members of a class which can only be accessed by that class and other methods of that class.
A private variable is one that is accessible only to the current class and cannot be accessed by any other class, including the ones that extend from it. A final variable is one that cannot be modified once it is initialized and assigned a value.
Java's bytecode would be referred to as an intermediate language, as it is neither human readable source code nor is it code which can be directly executed by a processor.
Let's take this in two parts. First, why is Java appropriate for web-based applications. There are Java plugins for most major web browsers, and Sun's Java comes with those plugins built into the install package. In this respect, it is easy to get your application online. Second, why is Java...
A semicolon ";" will end a Java statement
The size of an empty class is not normally 1 byte, actually. It will usually be equal to the word size defined by the platform it is running on (often 2 or 4 bytes). This is because the word size is usually used as a memory address size and an empty class still needs to point to some location in...
OOP(Object-Oriented Programming) provides a clear modular structure for programs which makes it good for defining abstract datatypes where implementation details are hidden and the unit has a clearly defined interface.
Users want to communicate with one another, without being restricted by incompatibility between different types of computers.
No.\n\n. A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be considered as an array of chars - Java stores it as an object.\n No.\n\n. A char is a single Unicode character. It is stored as a primitive (i.e., non-object) data. A string can be...
Better usage of resource available. . Task parallelism. SP.
That's what you call compilation.
Synchronization is the capability od controlling the access of multiple threads to any shared resource. It is used : 1) to prevent thread interface. 2)to prevent consistency problem
simply enter three nos. lyk a b and c and use the code a*b*c and print the result!!
Answer A compiler only converts source code to binary code for directexecution after compilation is complete, while an interpreterconverts source code to binary code in real time and executes thecode on behalf of the source code. Generally, interpreted code runsslower but is easier to find and fix...
Some differences are: . An abstract class can have code for one or more methods but an interface cannot . All variables in an interface are public static and final but in an abstract class it is not . Abstract classes are faster than interfaces
Let's say you want a method which will determine if the given character is a vowel, consonant, or other (non-letter). // Will return a String representation of what the given character is: // "vowel" "consonant" or "other" public static final String getTypeOfChar(final char c) { . // since...
Runtime exceptions are referred to as unchecked exceptions. All other exceptions are checked exceptions, and they don't derive from java.lang.RuntimeException. A checked exception must be caught somewhere in your code. If you invoke a method that throws a checked exception but you don't catch the...
If it is already sorted, the best is to leave the array as it is.\n If it is already sorted, the best is to leave the array as it is.\n If it is already sorted, the best is to leave the array as it is.\n If it is already sorted, the best is to leave the array as it is.\n
Java uses only pass by value. Primitive data types are passed purely as pass by value whereas for objects a value which is the reference to the object is passed. Hence the whole object is not passed but its reference gets passed. All modifications to the object in the method would modify the object...
Garbage collection refers to eliminating objects that are no longer accessible, and thus free up the space they use. In Java, for example, once a variable that refers to an object no longer exists (when the method in which it was declared ends execution), the object is usually no longer accessible....
for example: javac First.java Second.java
Abstraction of data is a natural base for OOP. OOP deals with objects does not matter what kind of nature. In order to accomplish that, certain data should exist which could describe any other types in terms of its properties. Such data type is abstract data which can be any particular type.
you mean JavaApplet or Ajax? I do not think you can compare java as a whole and AJAX. Ajax is a simple implementation of JAvascript .
a variable holds a single type of literal. i.e. 1, bat, 345. A object is a instance of a class created by the a programmer with a set of methods which preforms certain task depending what methods have been defined. int a = 4; // a would be the variable Car b = new Car();// b is an object b...
In Java applications, use the Scanner class. For instance: import java.util.scanner; ... Scanner input = new Scanner(System.in); System.out.println("Type a word: "); String word = input.nextLine(); Oh, and by the way, the Scanner class didn't exist until jdk 1.5.
The compiler can detect all kinds of syntactical errors like: . referring to a method that doesnt exist . assigning objects of one type to another without explicit casting . trying to access private methods of another class . etc. The purpose of the compiler is to detect these kind of...
#include #include #include void draw_x(int width, int height); int main(int argc, char *argv[]){ int width, height; if(argc != 3){ printf("Syntax: this_program width height\n"); exit(1); . } width = atoi(argv[1]); height = atoi(argv[2]); // make sure they're both...