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 can you create user defined immutable object in java?

Define your own class which will have all members final

& methods to return values of variable only

/*

javavishal.blogspot.com

This code shows the way to make a class immutable

*/

// The immutable class

final class VImmutableClass

{

// instance var are made private & final to restrict the access

private final int prop1;

// Constructor where we can provide the constant value

public VImmutableClass(int vprop1)

{

prop1 = vprop1

}

// provide only methods which return the instance var

// & not change the values

public int getProp1()

{

return prop1;

}

}

// class MyImmutable

public class MyImmutable

{

public static void main(String[] args)

{

VImmutableClass obj1 = new VImmutableClass(3);

System.out.println(obj1.getProp1());

// there is no way to change the values of count & value-

// no method to call besides getXX, no subclassing, no public access to var -> Immutable

}

}

What happens when one string is appended to the end of another in Java?

This is called "concatenation", and pretty much just smashes the two Strings together. For example:

import java.util.*;

public class Example

{

public static void main(String[] args)

{

Scanner in = new Scanner(System.in);

System.out.println("Please enter a string: ");

String input = in.next();

System.out.println("Please enter another string: ");

String input2 = in.next();

String together = input + input2;

System.out.println("The strings concatenated yields: " + together);

}

}

OUTPUT:

Please enter a string:

Hello

Please enter another string:

Goodbye

The strings concatenated yields: HelloGoodbye

As well, you can use String.nextLine() to get more than one word per string:

import java.util.*;

public class Example

{

public static void main(String[] args)

{

Scanner in = new Scanner(System.in);

System.out.println("Please enter a string: ");

String input = in.nextLine();

System.out.println("Please enter another string: ");

String input2 = in.nextLine();

String together = input + input2;

System.out.println("The strings concatenated yields: " + together);

}

}

What are the eight Java primitives types and give it size?

A primitive variable can be one of eight types: char, boolean, byte, short, int, long, double, or float. Once a primitive has been declared, its primitive type can never change, although in most cases its value can change.

Primitive Data Type Ranges in JavaData TypeBits UsedMinimum ValueMaximum Valuebyte8-2727 - 1short16-215215 -1int32-231231 -1long64-263263 -1float32n/an/adouble64n/an/a

The range for these floating point numbers is difficult to determine. Booleans and char type variables do not have a range. Booleans can be either true or false and chars can be only one character in size Ex: "A" or "B" etc

What is the name of the function which must be defined in a Java program?

The main function. Every program must have a main function and it must be declared static.

Is it possible to have a method in the super class and sub class with same name but different signature?

Yes, it is perfectly possible. If two methods have a different signature, they can exist together irrespective of where they are present, either in the same class or in a super class, sub class situation.

If two methods have the same signature and one exists in the super class and one in the sub class it is called method overriding.

How do you call a member function of one class in another class using friend function?

class B; // forward declaration.

class A

{

private:

void myFunction(B b){b.myFunction();} // Calls private method in b.

};

class B

{

friend void A::myFunction(B b); // Friend function declaration.

private:

void MyFunction();

};

What is the Eyeball Method?

With the Eyeball Method, the dieter's hand is used to judge portion sizes. For low fat proteins (chicken and fish), the portion should be approximately the size and thickness of the dieter's palm.

What are the 8 methods of elaboration?

1. Action Verbs - words that depict action in the physical world.

Pottery, that's all it was / Pastelled with green, pink; / blotted with sunset and clear October mornings / I had never seen such beauty / A young woman / hair nested in a bun / clutching tight to her daughter (Lindsey Daugherty)

giggled, buzzed, watching, bubbles, circles, yawn, flailed, writhes, peeks, wag

2. Adjectives/Adverbs - describing words.

You were bone skinny, legs the size of a supermodel's arms, had dark tree-bark skin, two shades darker than mine. Your long, black hair was … Your pants were a pair of hundred-year-old-need-to-be-thrown-out-or-burned jeans. Your skinny feet were devoured by oversized working boots. (Sarah Mitchell)

Walking through the wheat fields that looked solemnly down on me, I would lose myself in the beauty of the day. The thin wheat stalks swaying beneath the sky whispered gloriously in unison. (Amy Kirch)

3. Allusions - brief of slight mention of someone or something to emphasize your point. In Jewel's Song "Stand," she uses allusion several times to refer to people in history.

Marvin Gaye, there's no brother, brother

Woody Guthrie's land can't feed Mother

While in the corner, King's dream dies

4. Analogies - A comparison between two things used to make a point or idea memorable: comparing lips to a rose or school to prison. They are often used in extended form in arguments. An argument based on analogy, for example, is as follows: advertising cigarettes is like manslaughter. Arguments by analogy are easily refuted since analogies can only hold so far.

5. Anecdotes - A short narrative account of an amusing, unusual, revealing, or interesting event.

I remember those days when I would just sit down on the bed and watch Daddy let black socls engulf his feet, squeeze his size-twelve feet into size-ten shoes, and I would be elated when he asked me to button his sleeves. When we walked out the door, he would always remind me, "Remember, we're not poor, so don't let anyone say that to you. We just have financial problems." (Jerrod Morgan)

6. Definitions - provide a definition of a term for explanation, for further description, to show the essential nature, to define boundaries, or to entertain.

The doctor gasped as he pulled some scary-looking object -- almost a perfect oval -and placed it on the table. He studied the "thing" as if he were a carrion-eating bird, a vulture swooping down on a freshly killed waterbuck, an antelope with a reddish-brown coat. The only apparent difference was that his coat was white. (Victoria Siegelman)

According to Webster's Dictionary, a government is the authority that serves the people and acts on their behalf. How can the government know what the people want if the people do not vote? If we do not vote, the government may act on its own behalf instead of on the behalf of the people.

7. Descriptions - provide MORE information about your topic (usually with adjectives and/or adverbs)

He was an 83-year old, my-way-or-the-highway, beer-drinking, cigar-smoking, cowboy-hat-wearing man that just so happened to be my grandfather. (Jose Campos)

8. Dialogue - using quotations. It can be dialogue between people, internal dialogue, or even an example or what someone might say.

We have all had "fake" friendships, people who have talked about us or done something behind our backs or simply made fun of us. Lots of people gossip about others just to make themselves look good or to be the center of attention, but people don't like liars. These "fake" friends might lie and say something like "Did you ear that Bob likes Barbara so Barbara broke up with nick because she said she never really liked him in the first place?" Or "I hear she's

What is a parameter in Excel?

A parameter is a value that is used to carry out of task. It can be interpreted in a few ways. Parameters can be the values used to define filters if querying data in Excel. So if you have a list of data and want to show only some of it based on some criteria, that criteria can be referred to as parameters.

If data is being read from an external source, it may require a parameter to define what data to show. Microsoft Access has something called a parameter query where a value is fed in at the time the query is run. That value is called a parameter. So if Excel is reading a parameter query from Access, it will need to provide a parameter to do it with.

A parameter can be a value that is used in a function, though that is more commonly called an argument. In order for many functions to work they need values to work on. These are called arguments or occasionally parameters.

What is user defined integrity?

Business rules may dictate that when a specific action occurs further actions should be triggered. For example, deletion of a record automatically writes that record to an audit table.

Oracle, and some other RDBMSs, will allow storage of the code to manage these rules within the database itself. That is, in a central data dictionary

What is a connection class in java?

to connect java and data base...use connection stament

What is the current version of JDK?

As of February 2, 2012 the latest public release of the standard edition of Java is Java Standard Edition(SE) 7 update 3.

How do you write a java program in which the user will enter an amount of money as a decimal number and the program will compute how many pennies nickels dimes quarters ones fives tens twenties etc.?

Denomination values should be stored in an integer array where each value is in pennies. So $100 is 10000 pennies:

const array<int,10> value = {10000, 5000, 2000, 500, 100, 50, 25, 10, 5, 1};

Create a parallel array with the actual denominations:

const array<string,10> denomination = {"hundreds", "fifties", "twenties", "fives", "dollars", "half", "quarters", "dimes", "nickels", "cents"};

Start by multiplying the amount by 100 to determine the actual number of pennies. So $1.23 becomes 123 pennies. Store this value as an integer named pennies.

Now work your way through the denominations in sequence:

for (int index=0; index<value.size() && pennies; ++index)

{

int number=pennies/value[index];

if (number)

cout<<number<<' '<<denomination[index]<<endl;

pennies%=value[index];

}

How do you say class objects in french?

Class objects or Glass Objects?

Class Objects is objets de classe

Glass objects is objets en verre

How do you execute all statement in try block if an exception occurs?

If you have an exception you should fix mistake in your try block. If you want to run some code even after exception was thrown you can use full form of try block:

try
{
...
}

catch (...)
{
...
}
finally
{
...
}

Where the statement finally is what you need. Make sure that the code you run within this statement is not able to trow exceptions.

What is Samsung java uploader?

It's used for uploading java games from you'r pc to you'r samsung mobile.

What is better to work with Java or Flash?

Im no expert but in my expeience ive noticed Flash to be far more common so id say Flash

How all objects will share single method copy?

A "static" method belongs to the class, not to any particular instance. So make it static method.

Why is romberg's method more accurate than Simpson's method?

It takes more values of the integrand into consideration in forming its estimate. Simpson's uses just three values in the domain of integration. Romberg's uses as many as required to achieve the desired accuracy. Please see the links.

What type of variable is gender?

Nominal (categorical), and Dependent (it is measured and accounted for, but a researcher cannot manipulate gender).