VR23 Object Oriented Programming through Java Lab



 
                         Object Oriented Programming through Java Lab 

Course Objectives: 

The aim of this course is to  

  • Practice object oriented programming in the Java programming language 
  • Implement Classes, Objects, Methods, Inheritance, Exception, Runtime            Polymorphism, User defined Exception handling mechanism 
  • Illustrate inheritance, Exception handling mechanism,  JDBC connectivity  
  • Construct Threads, Event Handling, implement packages, Java FX GUI 
Experiments covering the Topics: 
  • Object Oriented Programming fundamentals- data types, control structures 
  • Classes, methods, objects, Inheritance, polymorphism,  
  • Exception handling, Threads, Packages, Interfaces 
  • Files, I/O streams, JavaFX GUI 
Sample Experiments: 

Exercise – 1: 
a) Write a JAVA program to display default value of all primitive data type of JAVA   Program
b) Write a java program that display the roots of a quadratic equation ax2+bx=0. Calculate the discriminate D and basing on value of D, describe the nature of root.  Program
Exercise - 2: 
a) Write a JAVA program to search for an element in a given list of elements using binary search mechanism. Program
b) Write a JAVA program to sort for an element in a given list of elements using bubble sort   Program
c) Write a JAVA program using String Buffer to delete, remove character.   Program
Exercise - 3 :
a) Write a JAVA program to implement class mechanism. Create a class, methods and invoke them inside main method.  Program
b) Write a JAVA program implement method overloading. Program
c) Write a JAVA program to implement constructor. Program
d) Write a JAVA program to implement constructor overloading. Program
Exercise - 4 
a) Write a JAVA program to implement Single Inheritance   Program
b) Write a JAVA program to implement multi level Inheritance   Program

c) Write a JAVA program for abstract class to find areas of different shapes   Program
Exercise - 5 
a) Write a JAVA program give example for “super” keyword.   Program
b) Write a JAVA program to implement Interface. What kind of Inheritance can be achieved?  Program
c) Write a JAVA program that implements Runtime polymorphism  Program
Exercise - 6 
a) Write a JAVA program that describes exception handling mechanism  Program
b) Write a JAVA program Illustrating Multiple catch clauses   Program
c) Write a JAVA program for creation of Java Built-in Exceptions  
d) Write a JAVA program for creation of User Defined Exception  
Exercise - 7 
a) Write a JAVA program that creates threads by extending Thread class. First thread display “Good Morning “every 1 sec, the second thread displays “Hello “every 2 seconds and the third display “Welcome” every 3 seconds, (Repeat the same by implementing Runnable)   
b) Write a program illustrating is Alive and join () 
c) Write a Program illustrating Daemon Threads.   
d) Write a JAVA program Producer Consumer Problem 
Exercise – 8  
a) Write a JAVA program that import and use the user defined packages 
b) Without writing any code, build a GUI that display text in label and image in an Image View (use JavaFX) 
c) Build a Tip Calculator app using several JavaFX components and learn how to respond to user interactions with the GUI 



Exercise - 1 (Basics)


a). Write a JAVA program to display default value of all primitive data type of JAVA


import java.io.*;

class Primitivevalues

{

 static boolean B1;

 static byte T1; 

 static int I1; 

 static float F1;

 static double D1; 

 static char C1;

 public static void main(String args[])

 {


  System.out.println("static  variable  Default values for BYTE:"+T1);

  System.out.println("static  variable  Default values for INT:"+I1);

  System.out.println("static  variable  Default values for FLOAT:"+F1);

  System.out.println("static  variable  Default values for DOUBLE:"+D1);

  System.out.println("static  variable  Default values for CHAR:"+C1);

  System.out.println("static  variable  Default values for BOOLEAN:"+B1);

 }

}


b). Write a java program that display the roots of a quadratic equation ax2+bx=0. Calculate the discriminate D and basing on value of D, describe the nature of root.




import java.io.*;

import static java.lang.Math.sqrt;

import java.util.*;

class Roots

{


  void m1(int a,int b,int c)

 {

  double value=(Math.pow(b,2.0)-4*a*c);

   double discriminant=(double)Math.sqrt(value);

  if(value>0)

  {

   System.out.println("Roots are real numbers");

   double root1=(discriminant-b)/(2*a);

      double root2=(-b-discriminant)/(2*a);

      System.out.println("FirstRoot"+root1+"\nSecond Root"+root2);

  }

  else if(value==0)

  {

   double root1=(discriminant-b)/(2*a);

   System.out.println("Polynomial has one Root"+root1);

  }

  if(value<0)

  {

   System.out.println("Roots are imaginary numbers");

   System.out.println((-b+"i"+"+"+(-1*value))+"/"+(2*a));

   System.out.println((-b+"i"+"-"+(-1*value))+"/"+(2*a));

  }



 }

 public static void main(String [] args)

  {

   int a,b,c;

   System.out.print("Enter a,b,c values:");

   Scanner br=new Scanner(System.in);

    a=br.nextInt();

    b=br.nextInt();

    c=br.nextInt();

    new Roots().m1(a,b,c);

  }

}


Exercise - 2 (Operations, Expressions, Control-flow, Strings)


a). Write a JAVA program to search for an element in a given list of elements using binary search mechanism.


import java.util.Scanner;

import java.io.*;

class Binarys

{

  public static void main(String args[])

   {

      int c,first,last,middle,n,search,array[];

      boolean status=false;

       Scanner s=new Scanner(System.in);

       System.out.println("Enter number of elements:");

       n=s.nextInt();

       array=new int[n];

        System.out.println("Enter"+n+"integer:");

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

        array[c]=s.nextInt();

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

         {

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

            {

                if (array[i] > array[j])

                {

                  int  temp = array[i];

                    array[i] = array[j];

                    array[j] = temp;

                }

            }

      }

        System.out.println("Enter value to find:");

        search=s.nextInt();

        first=0;

        last=n-1;

        middle=(first+last)/2;

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

     {

        if(first<=last)

         {

             if(array[middle]<search)

                  first=middle+1;

             else if(array[middle]==search)

              {

                  status=true;

              }

           else

            {

                last=middle-1;

            }

                 middle=(first+last)/2;

         }

    }

       if(status==true)

       {

           System.out.println(search+"found at location"+(middle+1));

       }

     else

         System.out.println(search+"is not found in the list");

   }

}

       

b). Write a JAVA program to sort for an element in a given list of elements using bubble sort.


import java.util.Scanner;

public class Bubblesort

{

 public static void main(String[] args)

 {

         Scanner s=new Scanner(System.in);

         System.out.println("enter the size of the array:");

         int size=s.nextInt();

         System.out.println("enter the values into the array:");

         int arr[]=new int[size];

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

         {

              arr[i]=s.nextInt();

         }

         sorting(arr);

     }

     public static void sorting(int arr[])

     {

         int n=arr.length;

         int temp=0;

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

         {

           for(int j=1;j<(n-i);j++)

          {

            if(arr[j-1]>arr[j])

            {

               temp=arr[j-1];

               arr[j-1]=arr[j];

               arr[j]=temp;

            }

          }

        }

         System.out.println("the sorted arraty is:");

         for(int i=0;i<arr.length;i++)

         {

            System.out.print(arr[i]+"\t");

         }

     }

}

C) Write a JAVA program using StringBufferto delete, remove character.

import java.util.Scanner;
import java.lang.*;
class stringbuffer
{
  public static void main(String args[])
  {
     Scanner s=new Scanner(System.in);
     System.out.println("enter a string you like:");
     String str=s.nextLine();
     StringBuffer b=new StringBuffer(str);
     System.out.println("enter the index you want to delete from:");
      int i1=s.nextInt();
     System.out.println("to:");
     int i2=s.nextInt();
     b.delete(i1,i2);
     System.out.println("after deletion the new buffer is:"+b);
  }
}


 

netaji gandi Tuesday, May 28, 2024
MASTER OF COMPUTER APPLICATIONS (MCA) -WEB TECHNOLOGIES LAB (MCA3108)




Course Objectives: 

 • To implement the web pages using HTML and apply styles. 

 • Able to develop a dynamic webpage by the use of java script. 

 • Design to create structure of web page, to store the data in web document, and transport        information  through web. 

 • Able to write a well formed / valid XML document.

 

Course Outcomes (COs): 

At the end of the course, student will be able to 

 • Create dynamic and interactive web pages using HTML, CSS & Java Script 

 • Experiment with Learn and implement XML concepts 

 • Develop web applications using PHP 

 • Show the Install Tomcat Server and execute client-server programs 

 • Implement programs using Ruby programming

 

Experiment 1: 

 Develop static pages (using HTML and CSS) of an online book store. The pages should resemble: www.flipkart.com The website should consist the following pages. 

 a) Home page 

 b) Registration and user Login 

 c) User Profile Page 

 d) Books catalog 

 e) Shopping Cart

 f) Payment By credit card

 g) Order Conformation

 

Experiment 2: 

Create and save an XML document on the server, which contains 10 users information. Write a program, which takes User Id as an input and returns the user details by taking the user information from the XML document.

 

Experiment 3: 

 Write a PHP script to merge two arrays and sort them as numbers, in descending order. 

 

Experiment 4: 

Write a PHP script that reads data from one file and write into another file. 

 

Experiment 5: 

 Write a PHP script to print prime numbers between 1-50. 

 

 Experiment 6: 

 Validate the Registration, user login, user profile and payment by credit card pages using JavaScript.

 

 Experiment 7: 

 Write a PHP script to: a. Find the length of a string. b. Count no of words in a string. c. Reverse a string. d. Search for a specific string. 

 

Experiment 8: 

 Install TOMCAT web server. Convert the static web pages of assignments 2 into dynamic web pages using servlets and cookies. Hint: Users information (user id, password, credit card number) would be stored in web.xml. Each user should have a separate Shopping Cart. 

 

 Experiment 9: 

Redo the previous task using JSP by converting the static web pages of assignments 2 into dynamic web pages. Create a database with user information and books information. The books catalogue should be dynamically loaded from the database. Follow the MVC architecture while doing the website. 

 

 Experiment 10: 

Install a database(Mysql or Oracle). Create a table which should contain at least the following fields: name, password, email-id, phone number(these should hold the data from the registration form). Practice 'JDBC' connectivity. Write a java program/servlet/JSP to connect to that database and extract data from the tables and display them. Experiment with various SQL queries. Insert the details of the users who register with the web site, whenever a new user clicks the submit button in the registration page . 

 

Experiment 11: 

Write a JSP which does the following job: Insert the details of the 3 or 4 users who register with the web site (week9) by using registration form. Authenticate the user when he submits the login form using the user name and password from the database. 

 

 Experiment 12: 

Create a simple visual bean with a area filled with a color. The shape of the area depends on the property shape. If it is set to true then the shape of the area is Square and it is Circle, if it is false. The color of the area should be changed dynamically for every mouse click.

netaji gandi
VR23 Object Oriented Programming through Java

                                           


Object Oriented Programming through Java 

Course Objectives: 

  • identify Java language components and how they work together in applications 
  • Learn the fundamentals of object-oriented programming in Java, including defining  classes, invoking methods, using class libraries. 
  • learn how to extend Java classes with inheritance and dynamic binding and how to  use  exception handling in Java applications 
  • understand how to design applications with threads in Java 
  • understand how to use Java APIs for program development 

 

 

UNIT I


Object Oriented Programming: Basic concepts, Principles,  Program Structure in Java: Introduction, Writing Simple Java Programs, Elements or Tokens in Java Programs, Java Statements, Command Line  Arguments, User Input to Programs, Escape Sequences Comments, Programming Style.

Data Types, Variables, and Operators :Introduction, Data Types in Java, Declaration of Variables, Data Types, Type Casting, Scope of Variable Identifier, Literal Constants, Symbolic Constants, Formatted Output with printf()  Method, Static Variables and Methods, Attribute Final,  
Introduction to Operators, Precedence and Associativity of Operators, Assignment Operator ( = ), Basic Arithmetic Operators, Increment (++) and Decrement (- -)Operators, Ternary Operator, Relational Operators, Boolean Logical Operators, Bitwise Logical Operators
Control Statements: Introduction, if Expression, Nested if Expressions, if else Expressions, Ternary Operator?:, Switch Statement, Iteration Statements, while Expression, do–while Loop, for Loop, Nested for Loop, For–Each for Loop, Break Statement, Continue Statement.

                                                                Download


UNIT II


Classes and Objects: Introduction, Class Declaration and Modifiers, Class Members, Declaration of Class Objects, Assigning One Object to Another, Access Control for Class Members, Accessing Private Members of Class, Constructor Methods for Class, Overloaded Constructor Methods, Nested Classes, Final Class and Methods, Passing Arguments by Value and by Reference, Keyword this. 
Methods: Introduction, Defining Methods, Overloaded Methods, Overloaded Constructor Methods, Class Objects as Parameters in Methods, Access Control, Recursive Methods, Nesting of Methods, Overriding Methods, Attributes Final and Static. 

 Download


UNIT III


Arrays: Introduction, Declaration and Initialization of Arrays, Storage of Array in Computer Memory, Accessing Elements of Arrays, Operations on Array Elements, Assigning Array to Another Array, Dynamic Change of Array Size, Sorting of Arrays, Search for Values in Arrays, Class Arrays, Two dimensional Arrays, Arrays of Varying Lengths, Three-dimensional ArraysArrays as Vectors. 
Inheritance: Introduction, Process of Inheritance, Types of Inheritances, Universal Super Class-Object Class, Inhibiting Inheritance of Class Using Final, Access Control and Inheritance, Multilevel Inheritance, Application of Keyword Super, Constructor Method and Inheritance, Method Overriding, Dynamic Method Dispatch, Abstract Classes, Interfaces and Inheritance.  
Interfaces: Introduction, Declaration of Interface, Implementation of Interface, Multiple Interfaces, Nested Interfaces, Inheritance of Interfaces, Default Methods in Interfaces, Static Methods in Interface, Functional Interfaces, Annotations. 

 Download


UNIT IV


Packages and Java Library: Introduction, Defining Package, Importing Packages and Classes into Programs, Path and Class Path, Access Control, Packages in Java SE, Java.lang Package and its Classes, Class Object, Enumeration, class Math, Wrapper Classes, Auto-boxing and Auto unboxing, Java util Classes and Interfaces, Formatter Class, Random Class, Time Package, Class Instant (java.time.Instant), Formatting for Date/Time in Java, Temporal Adjusters Class, Temporal Adjusters Class. 
Exception Handling: Introduction, Hierarchy of Standard Exception Classes, Keywords throws and throw, try, catch, and finally Blocks, Multiple Catch Clauses, Class Throwable, Unchecked Exceptions, Checked Exceptions. 
Java I/O and File: Java I/O API, standard I/O streams, types, Byte streams, Character streams, Scanner class, Files in Java(Text Book 2)


UNIT V


String Handling in Java: Introduction, Interface Char Sequence, Class String, Methods for Extracting Characters from Strings, Comparison, Modifying, Searching; Class String Buffer.

Multithreaded Programming: Introduction, Need for Multiple Threads Multithreaded Programming for Multi-core Processor, Thread Class, Main Thread-Creation of New Threads, Thread States, Thread Priority Synchronization, Deadlock and Race Situations,  Inter-thread Communication - Suspending, Resuming, and Stopping of Threads
Java Database Connectivity: Introduction, JDBC Architecture, Installing MySQL and MySQL Connector/J, JDBC Environment Setup, Establishing JDBC Database Connections, ResultSet Interface 
Java FX GUI: Java FX Scene Builder, Java FX App Window Structure, displaying text and image, event handling, laying out nodes in scene graph, mouse events (Text Book 3)
  
 Download

netaji gandi
MASTER OF COMPUTER APPLICATIONS (MCA) -WEB TECHNOLOGIES (MCA3103)


 

                                         WEB TECHNOLOGIES

Course Objectives: 
To  Learn PHP language for server side scripting 
To introduce XML and processing of XML Data with Java 
To introduce Server side programming with Java Servlets and JSP 
To introduce Client side scripting with JavaScript. 


Course Outcomes (COs):

At the end of the course, student will be able to  
Analyze a web page and identify its elements and attributes. 
To acquire knowledge of xml fundamentals and usage of xml technology in electronic data interchange 
Build dynamic web pages using JavaScript (client side programming). 
To design and develop web based enterprise systems for the enterprises using technologies like jsp, servlet. 
Build web applications using PHP 


Unit I:  


Web Basics- Introduction, Concept of Internet- History of Internet, Protocols of Internet, World Wide Web, URL, Web Server, Web Browser. HTML- Introduction, History of HTML, Structure of HTML Document: Text Basics, Structure of HTML Document: Images and Multimedia, Links and webs, Document Layout, Creating Forms, Frames and Tables, Cascading style sheets. 


Unit II:  


XML Introduction- Introduction of XML,Defining XML tags, their attributes and values, Document Type Definition, XML Schemes, Document Object Model, XHTML Parsing XML Data – DOM and SAX Parsers in java. 


Unit III: 


Introduction to Servlets: Common Gateway Interface (CGI), Life cycle of a Servlet, deploying a Servlet, The Servlet API, Reading Servlet parameters, Reading Initialization parameters, Handling Http Request & Responses, Using Cookies and Sessions, connecting to a database using JDBC.

 

Unit IV: 

Introduction to JSP: The Anatomy of a JSP Page, JSP Processing, Declarations, Directives, Expressions, Code Snippets, implicit objects, Using Beans in JSP Pages, Using Cookies and session for session tracking, connecting to database in JSP. Client-side Scripting: Introduction to JavaScript, JavaScript languagedeclaring variables, scope of variables, functions. event handlers (onClick, onSubmit etc.), Document Object Model, Form validation. 


Unit V: 


Introduction to PHP: Declaring variables, data types, arrays, strings, operators, expressions, control structures, functions, reading data from web form controls like text boxes, radio buttons, lists etc., Handling File Uploads. Connecting to database (MySQL as reference), executing simple queries, handling results, Handling sessions and cookies File Handling in PHP: File operations like opening, closing, reading, writing, appending, deleting etc. on text and binary files, listing directories

netaji gandi

Web Development with PHP Course

  Course : Web Development with PHP The Importance Of PHP Web Development Website development is rapidly growing tool for business developme...