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

Sample code of loops and repetitions?

system.out.println(" print 1-100 numbers");

for(i=0;i<=100;i++)

system.out.println(i);

o/p1

2

3

4

5

.......

How do you initialize each element of a two-dimensional array alpha to 5?

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 (col = 0; col < COLS; col++{

alpha[row][col] = 5;

}

}

C plus plus program that display student name course and grade using arrays of strings?

enum field { name, course, grade }; std::string student[3];

student[name] = "Joe Bloggs";

student[course] = "C++ Programming";

student[grade] = "A+";

How do you implement a doubly linked list using only one reference value instead of the usual next and previous references?

store the exor of the previous node address and next node address in each node of single linked list .further exor the nodes to proceed forward or backward as necessary

How to declare an array in easytrieve that occurs 99999 times?

WS-DAYS-OF-WEEK W 10 A OCCURS 99999 refer: http://code.xmlgadgets.com/2010/09/20/occurs-clause-in-easytrieve/

What is a daemon thread?

A daemon thread is often called a "service thread" or a "nonessential thread". The other kind of thread is often called a "user thread."

The JVM will exit when all user threads have returned from their run methods. Once all of the user threads have returned, any active daemon threads will be forced to stop running.

Let's look at an abstract example to see the difference... Pretend you have written a client-server GUI-based chat client. You'll typically have at least one thread sitting around and listening for input from the other program (the server will listen for input from the client and the client will listen for input from the server). These threads can be set as daemon threads, because you don't want the JVM to keep executing if those are the only threads left.

Not let's look at the GUI for your programs. These will be run in a user thread, since you want to make sure that the JVM does not exit until the GUI thread finishes running (you will generally stop these threads from running when the user clicks to close the window).

What is Programming languege and why we use programming languege andexplain it?

A computer can do many different things, depending on the program provided to the computer. The program is a list of instructions.Rather than learn the "machine language", which is the underlying instructions the computer can execute, nowadays people usually program in a "programming language", which is closer to a human natural language, usually English. The instructions in this programming language are then converted into machine language, by programs specifically designed for that purpose (assemblers, compilers, and - in a way - interpreters).

Writing in a programming language is much easier than learning the machine language.

How objets call from class in java?

if we are acessing static members we can call them directly,while coming to non static members inorder to call object we have to call by using new operator......

Can an short value be assigned to int variable?

Yes, but you may cause truncation error because the short variable does not necessarily have the same range as an int variable. Most modern compilers will flag this as a warning. If you know that the value of the int variable will not exceed the range of a short variable, you can explicitly prevent the warning with a typecast, i.e. someShort = (short) someInt; and the compiler will assume that you know what you are doing.

What is an Array and to use Array in Action script?

Array is a ranged variable, using it is required by many actions.. like where you going to processing data from a file where there is n lines in a file and you want to get one line of it..

ex: if variable $line is an array of lines in a text file:

$line[1] is second line of the file... just keep it in mind arrays starts from zero :) it means line 1 of the file will be accessed with $line[0];

What is noun verb analysis in object oriented analysis and design?

Noun-verb analysis is a means of identifying classes and their methods. If you look in the "problem statement" (a statement that explains what a software application should do) for nouns, they will often wind up as classes. If you look for verbs, they will be methods of those classes.

A simple example of a problem statement might be:

We are a training facility. We need to be able to track the classes that students take. Classes are taught by teachers. Students enroll in classes. Each class is assigned to one teacher and one classroom.

So, we have classes, students, teachers and classrooms. Class will have methods like AssignTeacher and AssignClassroom. Students will have Enroll. Of course, there is more, such as how to handle the time of each class, and so on. But this gives an idea.

How do you identify which JPanel type panel caused the event in Java?

I never tried this, but it should work if you get the event source and cast it to a JPanel object. This is what it should look like:

JPanel newPanel = (JPanel) event.getSource();

What you did is assign the reference of the source panel to a new panel, and now you can go on with your code.

The most common function of an array is to store variables however there will be times when an array is used to store objects. briefly describe four such objects?

Any name can be placed in an array, be it a primitive name or an object name, even a function pointer. Four examples of common objects that may be placed in an array include any object defined in the STL (standard template library), which includes vectors, lists, iterators and maps. All are self-explanatory, although a vector is simply an array implemented as an object. Therefore an array of vectors is nothing more than an array of arrays (effectively a multi-dimensional array). However, vectors are the "correct" way of implementing arrays in C++ (unless you specifically wish to use C-style code in your C++ projects), thus a multi-dimensional array is best implemented as a vector of vectors.

When does this pointer get created?

When we call non static method with respect to class object then this pointer is created which keep the reference of that object.

Will the java compiler translate a source file that contains syntax errors?

No it will not. Any java source file that has syntax errors will not be translated fully. The compiler will spit out errors based on the syntax problems in your code.

Write a c program to find the maximum value of 25 element in an array?

int findMax(int *array)

{

int max = array[0];

for(int i = 1; i < array.length(); i++)

{

if(array[i] > max)

max = array[i]

}

return max;

}

What are the features differentiate java from c plus plus and c?

Java compiles to byte code suitable for interpretation by the Java virtual machine, whereas C and C++ both compile to native machine code. Thus C and C++ programs perform better than equivalent Java programs. However, Java programs can run on any machine with a suitable Java virtual machine implementation, which is pretty much everything these days. C and C++ programs must be compiled separately upon each supported platform, provided the source code is either generic or includes compiler directives to filter the platform-specific code. Java programs need only be compiled once, thus cross-platform development is greatly simplified, at the cost of performance.

C and Java cannot really be compared since C does not support object-oriented programming concepts. C++ is object-oriented but, unlike Java, it is not 100% object-oriented as it supports the concept of primitive data types that it inherited from C. Java is more closely related to C#, which is 100% object oriented.

What is active management by exception?

Active management by exception is a management approach that focuses on identifying and addressing significant deviations from planned performance or expected outcomes. Rather than monitoring every detail, managers concentrate on areas where performance falls short or exceeds targets, allowing for more efficient use of resources and time. This strategy enables organizations to respond quickly to issues or opportunities, fostering a more dynamic and proactive management style. Ultimately, it helps in prioritizing critical issues while keeping routine operations running smoothly.

Explain the significance of public and protected and private access specifiers in inheritance?

These are all access modifiers in Java.

a. Public - these are accessible anywhere. This is the least restrictive access specifier.

b. Private - these are accessible only inside the declaring class. This is the most restrictive access specifier.

c. Protected - these are in between public and private. These are accessible to all classes that inherit this class

d. Package - this is the default access specifier. These are accessible to all classes that are present in the same package as the contained class.

What is the native heap size?

The heap refers to the free store, which basically means the total unused memory available to you. The physical amount of memory will vary from system to system and the amount of memory available will depend upon how much is currently in use. However memory fragmentation means that while there may be sufficient physical memory available to meet an allocation request it does not follow that there is a large enough block of contiguous memory available, resulting in an out of memory error.

Modern systems use virtual memory addresses rather than physical ones. This allows the memory manager to physically move objects around in memory without affecting the virtual addresses allocated to those objects and thus makes it possible to consolidate memory fragments. Objects that are not in use can also be paged out to a disk file, thus making it seem like there's far more memory available than physically exists.

Write a recursive procedure to compute the factorial of a number?

#include <iostream>

using namespace std;

int main()

{

int i, number=0, factorial=1;

// User input must be an integer number between 1 and 10

while(number<1 number>10)

{

cout << "Enter integer number (1-10) = ";

cin >> number;

}

// Calculate the factorial with a FOR loop

for(i=1; i<=number; i++)

{

factorial = factorial*i;

}

// Output result

cout << "Factorial = " << factorial << endl;