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

What is the fundamental questions would you ask when designing forms and reports?

Without knowing the entire background to the form, can I -your customer- complete it without detailed help text? If not, consider using simpler/more common terms for frields.

Does it make sense considering your database design? If not, reconsider the form or your database.

Is it easy to program? If not, it could be more complex to a customer than you may think, or may be an incorrect way of approaching the problem at least.

Implementing stack operation using array representation with java program?

class MyStack implements Stack

{

private String a[]=new String[10];

private int top=0;

public void push(String value)

{

a[top]=value;

top++;

}

public String pop()

{

top--;

return a[top];

}

public int length()

{

return top;

}

public void print()

{

for(int i=0;i<top;i++)

System.out.println(a[i]);

}

}

public class StackOperations

{

public static void main(String args[])

{

MyStack ms = new MyStack();

ms.push("silpa");

ms.push("arti");

ms.print();

System.out.print("popped element is ");

System.out.println(ms.pop());

System.out.print("Now stack is with: ");

ms.print();

}

}

Why does an abstract class often define methods WITHOUT actually implementing them?

Because, it wants the implementing or child class to take care of the actual implementation details.

Whether sms is connectionless or connection oriented?

I would say it is connectionless, as it sends the message to the person to revive it without establishing the connection first so there's no way to know if they revived it.

How can i check a null at the end of an character array in java?

A character array, by nature, is a primitive-type data array. It can't contain a null value. You cannot cast a char as a null.

char[] charArray = {'1','2','s',null}; //this doesn't compile.

However, if you have an array of Character objects, then it's possible.

Character[] charArray = {'1','2','s',null}; //this DOES compile

A proposed algorithm is to initialize a test boolean as false, then use a for loop to iterate through the array. Set the flag to true (and break the loop) based upon whether one of the objects you run into is null. What you do from there is up to what the rest of your code says.

Why runtime exceptions are not checked at compile time in java?

Compile time error is any type of error that prevent a java program compile like a syntax error, a class not found, a bad file name for the defined class, a possible loss of precision when you are mixing different java data types and so on.

A runtime error means an error which happens, while the program is running. To deal with this kind of errors java define Exceptions. Exceptions are objects represents an abnormal condition in the flow of the program. It can be either checked or unchecked.

How do you determine which is outer loop or inner loop of the Baltimore beltway?

The outer loop goes counter clockwise, while the inner loop goes clockwise. For example, if you're driving from Fairfax, VA to Washington, DC you're going on the inner loop, and on the way back you're taking the outer loop.

When iam using jfreechart for plotting a linechart can i give a point in y axis and find the exact chart intersection point at x axis?

final XYSeries series1 = new XYSeries("First");

series1.add(1.0, 1.0);

// series1.add(2.0, 4.0);

// series1.add(3.0, 3.0);

// series1.add(4.0, 5.0);

// series1.add(5.0, 5.0);

// series1.add(6.0, 7.0);

// series1.add(7.0, 7.0);

// series1.add(8.0, 8.0);

final XYSeries series2 = new XYSeries("Second");

series2.add(1.0, 1.0);

// series2.add(2.0, 4.0);

// series2.add(3.0, 6.0);

// series2.add(4.0, 8.0);

// series2.add(5.0, 4.0);

// series2.add(6.0, 4.0);

// series2.add(7.0, 2.0);

// series2.add(8.0, 1.0);

final XYSeries series3 = new XYSeries("Third");

series3.add(1.0, 1.0);

// series3.add(4.0, 3.0);

// series3.add(5.0, 2.0);

// series3.add(6.0, 3.0);

// series3.add(7.0, 6.0);

// series3.add(8.0, 3.0);

// series3.add(9.0, 4.0);

// series3.add(10.0, 3.0);

final XYSeriesCollection dataset = new XYSeriesCollection();

dataset.addSeries(series1);

dataset.addSeries(series2);

dataset.addSeries(series3);

JFreeChart chart = ChartFactory.createXYLineChart(

"Line Chart Demo 6", // chart title

"X", // x axis label

"Y", // y axis label

dataset, // data

PlotOrientation.VERTICAL,

true, // include legend

true, // tooltips

false // urls

);

XYPlot xyPlot = (XYPlot) chart.getPlot();

xyPlot.setDomainCrosshairVisible(true);

xyPlot.setRangeCrosshairVisible(true);

XYItemRenderer renderer = xyPlot.getRenderer();

renderer.setSeriesPaint(0, Color.blue);

return chart;

Which type of data uses the least bandwidth?

Primitive data types are smaller in size and hence are efficient in processing and use the least bandwidth.

What is the default scope of bean in Spring framework?

In the Spring framework, the default scope of a bean is singleton. This means that a single instance of the bean is created and shared across the entire Spring container, ensuring that all requests for that bean return the same object. If a different scope is needed, such as prototype, request, session, or application, it can be specified using annotations or XML configuration.

Write a program to find all triad numbers below 1000 where the second number is twice the first and the third is three times the first number?

#include

#include

int main()

{

int i,j,k,l,m,n,p,q,temp,fno,secno,thirdno;

int arr[1][9];

cout<<"---------------------------------------ABRAR TARIQ-------------------------------"<

cout<<"Here are the all possible combinations of the triad numbers between 1 to 1000 ! cheers !"<

int a=0;

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

{

for(j=i+1;j<=1000;j++)

{

if(j==2*i)

{

fno=i;

secno=j;

}

if(j==3*i)

{

thirdno=3*i;

}

}

k=fno/100;

temp=fno%100;

l=temp/10;

m=temp%10;

arr[0][0]=k;

arr[0][1]=l;

arr[0][2]=m;

k=secno/100;

temp=secno%100;

l=temp/10;

m=temp%10;

arr[0][3]=k;

arr[0][4]=l;

arr[0][5]=m;

k=thirdno/100;

temp=thirdno%100;

l=temp/10;

m=temp%10;

arr[0][6]=k;

arr[0][7]=l;

arr[0][8]=m;

for(n=0;n<1;n++)

{

for(p=0;p<9;p++)

{

for(q=p+1;q<9;q++)

{

if(arr[n][p]==arr[n][q]arr[n][p]==0arr[n][q]==0)

{

a=1;

}

if(a==1)

break;

}

if(a==1)

{

a=0;

break;

}

}

if(p==9&&q==9&&a==0)

{

cout<<<","<<<","<<<

cout<<"---And---"<

}

}

return 0;

}

What is an adapter pattern?

An adapter pattern is a structural design pattern which translates one interface for a class into a compatible interface.

What are the differences between Objected Oriented Programming and Procedural Oriented Programming?

Procedural oriented programming generally consists of a main program line that executes and does whatever it's supposed to do (branching off statements, loops etc..). You could say it is very functionally oriented like C, Fortran.

OOP is more about the entities which perform the processes than about the processes themselves. This leads to encapsulation. For ex, if you want to design a procedural program that reads in a text file and inserts the data into a database, you would have a procedure that

1. Parses the text file according to what you want,

2. Construct the necessary queries for the database,

3. Establish a connection to the database and finally,

4. Perform the data insertion.

This in OOP would consist (off the top of my head) of 3 classes;

1. Parser class which gets the data out of the textfile.

2. The query builder which returns SQL queries.

3. A Database connector class which connects to the database and performs the queries.

Here we aren't concerned with the internals of the parser or query builder. All the connector cares about is that the parser returns a dataset in a specified format and that the querybuilder returns a set of appropriate queries given the dataset.

What is the difference between training and development?

Training is focused on individual tasks, all nuts and bolts ... how to turn a wrench. Also, training has a beginning and an end.

Development is the whole person concept. Not only teaching them how to turn the wrench, but also why we turn the wrench and challenging them to figure out a better way to turn that wrench. It is focused more on cultivating the individual to give them the tools to work upward through greater job and relationship complexities. The job of development has no end.

In the modern organization, staff development energizes an organization's culture by grooming it's future leaders.

Example of a enrollment system in a flowchart?

Well, an enrollment system in a flowchart will depend on how many enrollments and departments your company has. It is basically a customizable chart.

What can you do in the CUPS web interface?

In the CUPS (Common Unix Printing System) web interface, users can manage printers and print jobs, configure printer settings, and monitor print queues. It allows for the addition and removal of printers, adjustment of their properties, and troubleshooting of printing issues. Additionally, users can view detailed information about print jobs, including their status and owner, and can cancel or hold jobs as needed. The interface provides a user-friendly way to manage printing on Unix-like operating systems.

How much height to loop the loop?

The height of the loop depends on the entry speed The diameter is usually adjusted to provide 1g acceleration in the upward direction to the upside-down passengers.

Technically, if the entry speed is the variable, and you don't worry about smashing the passengers or the g-forces, the loop can be ANY size.

What is a stringbuilder and stringbuffer?

Strings are extremely useful but at the same time resource intensive too. In programs where numerous strings are used which need to be altered every now and then, it is advisable to use the StringBuffer or the StringBuilder class.

The java.lang.StringBuffer and java.lang.StringBuilder classes should be used when you have to make a lot of modifications to strings of characters. As we discussed in the previous chapter, String objects are immutable, so if you choose to do a lot of manipulations with String objects, you will end up with a lot of abandoned String objects in the String pool. On the other hand, objects of type StringBuffer and StringBuilder can be modified over and over again without leaving behind a great list of discarded String objects.

StringBuffer vs. StringBuilder

The StringBuilder class was added in Java 5. It has exactly the same API as the StringBuffer class, except StringBuilder is not thread safe. In other words, its methods are not synchronized. (For now just know that syncrhonized is used for thread safety and causes an overhead in terms of performance) Sun recommends that you use StringBuilder instead of StringBuffer whenever possible because StringBuilder will run faster. So apart from synchronization, anything we say about StringBuilder's methods holds true for StringBuffer's methods, and vice versa.