Posts

KTU OOP LAB JAVA CSL 203 BTech CS S3 - Dr Binu V P

About Me Scheme and Evaluation Syllabus and Practice Questions ******************************** How to do Java Programs in  Debian PART A Basic Java Programs Using Control  Statements 1.String Problems 2.Numerical Problems 3.Arrays 4.Matrix Lab Exercise Java-1 PART B  Object Oriented Programming 1.Creating classes and objects. constructor for initializing object 2.Method overloading in Java 3.Single Inheritance 4.Multilevel Inheritance 5.Method overriding in Java 6. Hierarchical Inheritance 7.Interface in Java 8.Abstract classes in java  PART C Exception and File Handling 1.Exception Handling in Java 2.Reading and Writing Text Files 3.Buffered Reader and String Tokenizer PART D Multi-Threading  Creating Threads in Java Thread Synchronization in Java Thread Priorities in Java Programs using Multi-Threading PART E Graphics and Database Programming Introduction to Java Swing Drawing Shapes Drawing  a Sine Wave Handling Mouse Events Handling Keyboard Events Drawing Shapes with Mouse Events

KTU OOP LAB JAVA CSL 203 Scheme and Evaluation

Preamble: The aim of the course is to provide hands-on experience to the learners on various object oriented concepts in Java Programming. This course helps the learners to enhance the capability to design and implement various Java applications for real world problems. Prerequisite: Topics covered under the course Programming in C (EST 102) Course Outcomes: At the end of the course, the student should be able to CO1:Implement the Object Oriented concepts - constructors, inheritance, method overloading & overriding and polymorphism in Java (Cognitive Knowledge Level:Apply) CO2:Implement programs in Java which use datatypes, operators, control statements, built in packages & interfaces, Input/Output streams and Files (Cognitive Knowledge Level: Apply) CO3:Implement robust application programs in Java using exception handling (Cognitive Knowledge Level: Apply) CO4 :Implement application programs in Java using multithreading and database connectivity (Cognitive Knowledge Level: A

String Problems

Reverse a String import java.util.Scanner; public class ReverseString { public static void main(String[] args) {      Scanner scanner = new Scanner(System.in);      System.out.print("Enter a string to reverse: ");      String input = scanner.nextLine();      String reversed = new StringBuilder(input).reverse().toString();      System.out.println("Reversed string: " + reversed);      scanner.close(); } } without using StringBuilder import java.util.Scanner; public class ReverseString {     public static void main(String[] args) {         Scanner scanner = new Scanner(System.in);         System.out.print("Enter a string to reverse: ");         String input = scanner.nextLine();         // Manually reverse the string         String reversed = "";         for (int i = input.length() - 1; i >= 0; i--) {             reversed += input.charAt(i);         }         System.out.println("Reversed string: " + reversed);                  scanner.c

How to do Java Programs in Debian

Image
  1. Install Java Development Kit (JDK) First, ensure you have the JDK installed. You can install it using the package manager: sudo apt update sudo apt install default-jdk 2. Verify the Installation Check if Java is installed correctly: java -version 3. Write the Java Program Create a directory for your Java program and navigate to it:sh mkdir  /java_programs cd  /java_programs Create a file named HelloWorld.java using your preferred text editor (e.g., nano, vim,edit ) gedit HelloWorld.java Add the following code to the file: public class HelloWorld {   public static void main(String[] args)  {   System.out.println("Hello, World!");   }  } Save the file and exit the text editor. 4. Compile the Java Program Compile the Java program using the javac command: javac HelloWorld.java This will generate a file named HelloWorld.class. 5. Run the Java Program Run the compiled Java program using the java command: java HelloWorld You should see the output: Hello, World! Naming Conventio

Syllabus and Practice Questions KTU OOPS Lab Java CSL 203

SYLLABUS The syllabus contains six sessions (A, B, C, D, E, F). Each session consists of three concrete Java exercises, out of which at least two questions are mandatory. (A) Basic programs using datatypes, operators, and control statements in Java. 1) Write a Java program that checks whether a given string is a palindrome or not. Ex: MALAYALAM is palindrome. 2) Write a Java Program to find the frequency of a given character in a string. ** 3) Write a Java program to multiply two given matrices. ** (B) Object Oriented Programming Concepts: Problem on the use of constructors, inheritance,  method overloading & overriding, polymorphism and garbage collection: 4) Write a Java program which creates a class named 'Employee' having the following  members: Name, Age, Phone number, Address, Salary. It also has a method named 'print-Salary( )' which prints the salary of the Employee. Two classes 'Officer' and 'Manager' inherits the 'Employee' class. T

Arrays

Find the max element in an array import java.util.Scanner; public class FindMaxInArray {     public static void main(String[] args) {         Scanner scanner = new Scanner(System.in);         System.out.print("Enter the number of elements in the array: ");         int n = scanner.nextInt();         int[] numbers = new int[n];         System.out.println("Enter the elements of the array:");         for (int i = 0; i < n; i++) {             numbers[i] = scanner.nextInt();         }         scanner.close();         int max = numbers[0];         for (int i = 1; i < numbers.length; i++) {             if (numbers[i] > max) {                 max = numbers[i];             }         }         System.out.println("Maximum number in the array: " + max);     } } ************************************************************ Reversing an Array import java.util.Scanner; public class ReverseArray {     public static void main(String[] args) {         Scanner scanner

Numerical Problems

Find Roots of a quadratic equation import java.util.Scanner; public class QuadraticEquation { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter the coefficient a: "); double a = scanner.nextDouble(); System.out.print("Enter the coefficient b: "); double b = scanner.nextDouble(); System.out.print("Enter the coefficient c: "); double c = scanner.nextDouble(); double discriminant = b * b - 4 * a * c; double root1, root2; if (discriminant > 0) {      root1 = (-b + Math.sqrt(discriminant)) / (2 * a);      root2 = (-b - Math.sqrt(discriminant)) / (2 * a);      System.out.println("The roots are real and different.");      System.out.println("Root 1: " + root1);      System.out.println("Root 2: " + root2);         } else if (discriminant == 0) { root1 = root2 = -b / (2 * a); System.out.println("The roots are real and the same."); System.out.println("Root 1 = Ro