Tuesday, September 8, 2015

Sample Objects of different Classes

Classes used to create the above components are as follows:

Component NameClass Name
FrameJFrame
PanelJPanel
ButtonJButton
LabelJLabel
TextFieldJTextField
RadioButtonJRadioButton
ChekBoxJCheckBox
ComboBoxJComboBox



JFrame frame = new JFrame("Welcome");

JPanel panel = new JPanel();

JLabel lblusername = new JLabel("User Name");

JTextField txtusername = new JTextField(30);

JButton btnOk = new JButton("OK");

JRadioButton rbMale = new JRadioButton();

JCheckBox cbHobby = new JCheckBox();

JComboBox cbxCity = new JComboBox();

How to create a object of button class in java


JButton btnOk = new JButton("OK");

here JButton is a class, btnOk is a object of the class JButton.


new is a keyword which allocate memory to btnOk object after taking it from Constructor (JButton()).

here constructor is passing parameter as "OK" which will be displayed on the button.

Basic Java Interface

Let's understand simple Java interface


In the above picture we have create a Frame using JFrame class of Java.
Other components add are like as follows
  1. Frame
  2. Panel
  3. Button
  4. Label
  5. TextField
Classes used to create the above components are as follows:

Component NameClass Name
FrameJFrame
PanelJPanel
ButtonJButton
LabelJLabel
TextFieldJTextField
RadioButtonJRadioButton
ChekBoxJCheckBox
ComboBoxJComboBox

Sunday, August 23, 2015

While Loop Questions

Predict the output of the following codes:

1. int i=0;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");

}


2.   int i=110;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
}


3.  int i=0;
while(i<10);
{
JOptionPane.showMessageDialog(rootPane,"hello");
i=i+1;
}


4.   int i=0;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
i++;
}


5.  int i=0;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
i--;
}


6.  int i=0;
while(i==10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
}


7.  while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
}


8.  int i=0;
while(i<10)
{
JOptionPane.showMessage Dialog(rootPane. "hello");
}


9. int i=0;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
i=10;
}


10. int i=0;
while(i<10)
{
JOptionPane.showMessageDialog(rootPane,"hello");
i=i+1;
i=i-1;
}

11.

while(1)
{
JOptionPane.showMessageDialog(rootPane,"hello");
}

Tuesday, August 18, 2015

if Construct



int age;
age=Integer.parseInt(jTextField1.getText());
if(age<=0)
{
    jLabel2.setText("ERROR");
}
else
{
    if(age>0 && age<=50 )
    {
        jLabel2.setText("Young Age");
    }
    else
    {
        jLabel2.setText("Old Age");
    }
}

Monday, August 17, 2015

List of Programs

1. Write a code to count the number of days.
2. finding  the odd number
3. Create a scoreboard of hockey match
4. Replace a given word with another word
5. Create a login Form
6. Find the largest number out of given 3 numbers
7. Create a discount calculator
8. Write a code to check voter eligibilty age.
9. Write a code to complete your name. accept first, middle, last name.
10. Create a arithmatic operation calculator.
11. Create a color changer form
12. Write a code to count the character in a string.
13. Write a code to reverse the string.
14. Write a code to copy a given string.
15. Write a code to create commission calculator.
16. write a code check the number is palindrome.
17. write a code to reverse the number example. 1234 to 4321.
18. write a code to print the table of any number.
19. Enter any number and display the day of week?
20. Enter any number and display the month?

Friday, August 14, 2015

JAVA

Java is an internet programming language.

Java has 2 types of programming techniques.
1. C U I  (Character User Interface) Programming in this type of technique user can develop the command based applications. These application we can run from command prompt in windows.
2. G U I (Graphical User Interface) programming. In this type of technique user can develop the graphical interface application just like tally, notepad and many games.

Programming is a set of programs written in a specific language to achieve particular task.

Program is a set of instruction.

Different programming languages are C,C++, Java, VB.Net, C#, C#.Net, PHP.

While creating a project in any programming language we have to take care of 2 things, one is FRONT END and second is BACK END.

Front End is created in any Programming Language.

Back End is created using a RDBMS (Relational Database Management System). Its a place were data from the front end is saved.

To write a code in java we can use different IDE (Integrated Development Environment).
Like Net beans, Eclipse, Blue J or we can use simple Notepad.

Netbeans:


                 

Eclipse: