answersLogoWhite

0

📱

Java 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.

5,203 Questions

How do you create string array in java?

String[] myStringArray = { "abc","def","xyz" };

You can access elements of this array by using the [index] operation.

Ex:

myStringArray[0] will contain value "abc" and

myStringArray[1] will contain value "def" and so on...

Electricity bill preparation source codes in java?

import java.io.*;

import java.lang.*;

class electricity extends Exception

{

int b1;

electricity(int b)

{

b1=b;

System.out.println("\n\t\t Exception will caught below ");

}

}

class electric

{

static void compute(int a,int b,String name,String bno)throws IOException,electricity

{

name=name;

bno=bno;

if(b<a)

throw new electricity(b);

else

{

int tmr,amt=0,z=0;

tmr=b-a;

do

{

DataInputStream in=new DataInputStream(System.in);

System.out.println("\n\t Click any purpose ");

System.out.println("\n\t\t 1-Domestic ");

System.out.println("\n\t\t 2-Agriculture ");

System.out.println("\n\t\t 3-Industry ");

System.out.println("\n\t\t 4.Exit");

System.out.println("\n\n\t\t Enter ur Choice :");

int ch=Integer.parseInt(in.readLine());

switch(ch)

{

case 1:

if(tmr<=100)

amt =tmr *2;

else if(tmr >100 && tmr <=200)

amt=(tmr-100) *4 +100*2;

System.out.println("\n\n\t\t **********************************************");

System.out.println("\t\t\t Electricity Bill Preparation ");

System.out.println("\t\t **********************************************\n\n");

System.out.println("\n\t\t Name : " +name + " Bill no : " + bno );

System.out.println("\n\t\t Previous Meter Reading : " +a );

System.out.println("\n\t\t Closed Meter Reading :" +b );

System.out.println("\n\t\t Current Meter Reading :" +tmr );

System.out.println("\n\t\t Purpose : Domestic " );

System.out.println("\n\t\t Total Amount Rs. :" +amt );

break;

case 2:

if(tmr<=100)

amt =tmr *0;

else if(tmr >100 && tmr<=200)

amt=(tmr-100) *1 +100*0;

System.out.println("\n\n\t\t **********************************************");

System.out.println("\t\t\t Electricity Bill Preparation ");

System.out.println("\t\t **********************************************\n\n");

System.out.println("\n\t\t Name : " +name + " Bill no : " + bno );

System.out.println("\n\t\t Previous Meter Reading : " +a );

System.out.println("\n\t\t Closed Meter Reading :" +b );

System.out.println("\n\t\t Current Meter Reading :" +tmr );

System.out.println("\n\t\t Purpose : Agriculture " );

System.out.println("\n\t\t Total Amount Rs. :" +amt );

break;

case 3:

if(tmr<=100)

amt =tmr *4;

else if(tmr >100 && tmr<=200)

amt=(tmr-100) *8 +100*4;

System.out.println("\n\n\t\t **********************************************");

System.out.println("\t\t\t Electricity Bill Preparation ");

System.out.println("\t\t **********************************************\n\n");

System.out.println("\n\t\t Name : " +name + " Bill no : " + bno );

System.out.println("\n\t\t Previous Meter Reading : " +a );

System.out.println("\n\t\t Closed Meter Reading :" +b );

System.out.println("\n\t\t Current Meter Reading :" +tmr );

System.out.println("\n\t\t Purpose : Industry " );

System.out.println("\n\t\t Total Amount Rs. :" +amt );

break;

case 4:

System.exit(0);

}

System.out.println("\n\t Continue :");

z=Integer.parseInt(in.readLine());

} while(z==1);

}

}

public static void main(String ar[])throws IOException

{

electric ee=new electric();

String name,bno;

int pmr,cmr;

DataInputStream in=new DataInputStream(System.in);

System.out.println("\n\t ELECTRICITY BILL USING USERDEFINED EXCEPTION ");

System.out.print("\n\t\t Enter the name : ");

name=in.readLine();

System.out.print("\n\t\t Enter the Bill Number :");

bno=in.readLine();

System.out.print("\n\t\t Previous Meter Reading : ");

pmr=Integer.parseInt(in.readLine());

System.out.print("\n\t\t Current Meter Reading : ");

cmr=Integer.parseInt(in.readLine());

try

{

compute(pmr,cmr,name,bno);

}

catch(Exception e)

{

System.out.println("\n\t\tUserDefined Exception is found");

}

}

}

Program for marksheet in c language?

The std::cout and std::cin streams are peculiar to the C++ standard library. They are not available in the C standard library, but are analogous to stdin and stdout which is in the C standard library.

When ana Rosa said ''i was a balloon finally free of it string '' what two things was she comparing?

The two things she was comparing are (1) the baloon, and (2) herself.

The two things she was comparing are (1) the baloon, and (2) herself.

The two things she was comparing are (1) the baloon, and (2) herself.

The two things she was comparing are (1) the baloon, and (2) herself.

Program that prints every integer value from 1 to 20 along with its squared in java?

public class PrintValues {

public static void main(String[] args) {

for (int i = 1; i <=20; i++) {

System.out.println("Value is: " + i);

int sq = i * i;

System.out.println(i + " Squared is: " + sq);

}

}

}

Java Program requests and reads three lines of text and output the total number of characters entered sample code?

// 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 text:\n", numberOfLines);

for (int i = 0; i < numberOfLines; i++) {

String line = reader.readLine();

// increment the counter with the number of characters entered in current line

numberOfChars += line.length();

}

// print the number of characters entered

System.out.println("Number of characters entered: " + numberOfChars);

What is the difference between the or logical operator and the Xor operator?

The or operator will evaluate to true if either side of the operation is true.

The xor operator will evaluate to true only if exactly one side of the operation is true.

This means that these two operators will evaluate equally for all cases except when both sides of the operations are true.

true or true -> true

true xor true -> false

Write a program to determine the weighted arithmetic mean using C language?

#include

void mean(int[],int);

void main()

{

int n,a[24];

printf("Enter the number of terms to find mean\n");

scanf("%d",&n);

printf("Enter the numbers\n");

for(i=0;i

scanf("%d",&a[i]);

mean(a,n);

}

void mean(int a[24],int n)

{

int sum=0,mean;

for(i=0;i

sum+=a[i];

mean=sum/n;

printf("The mean of given values is %d",mean);

}

What is array processor and what is the role of attached array processor?

aray processor is a processor that performs computations on large arrays of data.

It is of two types:

(1) attached array processor.

(2)SIMD array processor.

What is phantom memory in java?

Phantom memory is a false memory which doesnt exist in reality .These references are available to collect byGC

Write a program to print 246810?

int main (void)

{

long int x = 246810

printf("%ld", x);

return 0;

}

List a few area of application of oop's technique?

1.real time system

2.decision support system

3.neural network

4.simulation and modelling

5.office automation

hope u got the answer,junaidniit

What is an index in Java?

An index is basically a numeric association to an element in a collection of data.

When you talk about an index in Java, you will most often be talking about the position of an object in an array.

int[] numbers = new int[] {10, 20, 30, 40};

Given the array declared above:

numbers[0] = 10 <- Element at index 0 is 10
numbers[1] = 20 <- Element at index 1 is 20
numbers[2] = 30 <- Element at index 2 is 30
numbers[3] = 40 <- Element at index 3 is 40

Do you need java for frostwire?

Yes. Java 1.5 or later (1.6 Recommended)

http://www.frostwire.com/?id=downloads

Why applet is more appropriate in internet?

Applets can be easily embedded in an HTML page for graphical presentation.Since

applets java programs so the write once run anywhere.It is flexible also.Apart from

this applets are executed in almost every browser.

Write a recursive method to compute the number of digits in a positive integer?

Such a method could be: public int NumberOfDigits(int num) { num = num/10; if( num == 0) return 1; return ( 1+NumberOfDigits(num) ); }

Distinguish between Dynamic binding and message passing?

Dynamic binding in java is the mechanism bywhich compiler cannot determine which method implementation to use in advance. Basedon the class of the object, the runtime system selects the appropriate method at runtime.Dynamic binding is also needed when the compiler determines that there is more than onepossible method that can be executed by a particular call.Java's program units, classes, are loaded dynamically (when needed) by the Java run-time system. Loaded classes arethen dynamically linked with existing classes to form an integrated unit. The lengthy link-and-load step required by third-generation programming languages is eliminated.Message Passing: In an object based world the only way for anything to happen is by objects communicating with eachother and acting on the results. This communication is called message passing and involves one object sending amessage to another and (possibly) receiving a resu

What Bytes occupied by double data type in c?

The number of bytes occupied by a specific data type depends on the implementation. In general, the double data type is eight bytes long, but you can check it using sizeof(double). In 16-bit,32-bit compilers double size is

8 bytes.It looks like float because it stores scientific and financial like big float values.