Menu
Question Index
...


Write a program to create the update statement for Oracle. If present, the id field should be placed at the beginning and the rest of fields should be sorted.

Input (Object) Output (String)
College object
---------------
Id=8099
Number of Students=75896
Number of Branches=6
Number of Faculty=1200
College Code="RITA"
Address="B K Samudram Mandal-Anantapur"
College Name="Srinivasa Ramanujan Institute of Technology"
UPDATE COLLEGE SET ADDRESS = "B K SAMUDRAM MANDAL-ANANTAPUR", COLLEGECODE = "RITA", COLLEGENAME = "SRINIVASA RAMANUJAN INSTITUTE OF TECHNOLOGY", NUMBEROFBRANCHES = 6, NUMBEROFFACULTY = 1200, NUMBEROFSTUDENTS = 75896 WHERE ID = 8099;
Mobile object
------------------
Company Name="Samsung"
Id=323537
Model Name="GT-S6102"
Price=8500
Pixel=3.2f
Resolution="240 x 320"
UPDATE MOBILE SET COMPANYNAME = "SAMSUNG", MEMORY = 160.0, MODELNAME = "GT-S6102", PIXEL = 3.2, PRICE = 8500.0, RESOLUTION = "240 X 320" WHERE ID = 323537;
Student object
----------------
Gender=true
Id=15
Section='A'
Name="Kiran Oleti"
Marks=1100
Percentage=98.9
UPDATE STUDENT SET GENDER = TRUE, MARKS = 1100, NAME = "KIRAN OLETI", PERCENTAGE = 98.9, SECTION = 'A' WHERE ID = 15;
Employee object
---------------
Salary=200000
Name="Narayana"
Designation="Software Engineer"
Id=2516
Gender=true
UPDATE EMPLOYEE SET DESIGNATION = "SOFTWARE ENGINEER", GENDER = TRUE, NAME = "NARAYANA", SALARY = 200000.0 WHERE ID = 2516;

class CreateUpdateQueryForOracle

{    public static void main(String s[])
    {
        College college = new College();
        college.id = 50;
        college.numberOfStudents = 75896;
        college.numberOfBranches = 6;
        college.numberOfFaculty = 1200;
        college.collegeCode = "RITA";
        college.address = "B K Samudram Mandal-Anantapur";
        college.collegeName = "Srinivasa Ramanujan Institute of Technology";
        String query = createUpdateQuery(college);
        System.out.println(query);

    }


public static String createUpdateQuery(Object object) {
String result = null;
//Write code here to create the update query for the given object
return result;
}

//If required write any additional methods here
}
class Student {

String name;
boolean gender;
int marks;
double percentage;
char section;
int id;
}

class Employee {

double salary;
String name;
String designation;
int id;
boolean gender;
}

class Mobile {

int id;
String companyName;
String modelName;
double price;
double memory;
float pixel;
String resolution;
}

class College {

int id;
int numberOfStudents;
int numberOfBranches;
int numberOfFaculty;
String collegeCode;
String address;
String collegeName;
}

Doubts

Problems

Topic: Other Advanced Topics In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App