Posts

TY B.B.A. (C.A.) Sem V : Core Java Practical Slips Solutions

    SAVITRIBAI PHULE PUNE UNIVERSITY, PUNE T.Y.B.B.A.(C.A.) Semester – V (CBCS 2019 Pattern) University Practical Examination Lab Course: (CA-506) Computer Laboratory Based on 503, 504 Core Java, MongoDB / Python Q.1. Core Java: Slip No. 1 /** A) Write a ‘java’ program to display characters from ‘A’ to ‘Z’. */ class Slip1_A   {     public static void main(String args[])     {         for(char ch = 'A' ; ch <= 'Z'; ch++)         {             System.out.print(ch+" ");         }     }   } /** B) Write a ‘java’ program to copy only non-numeric data from one file to another file. */ import java.io.*; class Slip1_B { public static void main(String args[]) throws IOException { File ifile = new File("in.dat"); File ofile = new File("out.dat"); try{ FileReader in = new FileReader(ifile); FileWriter out = new FileWriter(ofil...

Practical Implementation of Singleton Class

Image
Practical Implementation of Singleton Class   class Singleton {     public static void main(String args[])     {         Thread t = new Thread(new Runnable(){             public void run()             {                 DatabaseConnection obj = DatabaseConnection.getInstance();             }         });         Thread t1 = new Thread(new Runnable(){             public void run()             {                 DatabaseConnection obj = DatabaseConnection.getInstance();             }         });         t.start();         t1.start();     } } class DatabaseConnection{     pri...

TYBSc (CS) Sem V : Object Oriented Programming Using Java I Practical Slips Solutions

Image
SAVITRIBAI PHULE PUNE UNIVERSITY, PUNE T . Y. B.Sc. (Computer Science) Semester V Practical Examination       SUBJECT: CS-359 Practical course based on  CS-355 (Object Oriented Programming Using Java I) Slip No. 1 /* Q1) Write a Program to print all Prime numbers in an array of ‘n’ elements.  (use command line arguments) */ class Slip1 { public static void main(String args[]) { System.out.println("The prime numbers are: "); for(int i = 0; i < args.length; i++) { boolean isPrime= true; int num = Integer.parseInt(args[i]); for(int j = 2; j < num; j++) { if(num%j == 0) { isPrime = false; break; } } if( isPrime == true) { System.out.println(num); } } } } How run it: /* Q. 2 - Define an abstract class Staff with protected memebers id and name.  Define a parameterized constructor. Define one subclass OfficeStaff with member department. Create n object of OfficeStaff and di...