0% found this document useful (0 votes)
110 views18 pages

1.Class,method,object answer

The document provides an introduction to Java, covering fundamental concepts such as classes, methods, and objects. It includes theoretical questions and answers about Java's platform independence, open source, and differences between JDK, JRE, and JVM, as well as practical programming exercises demonstrating coding standards and object creation. Additionally, it outlines various Java features and comparisons with C++, along with sample projects and their implementations.

Uploaded by

kirthu ale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views18 pages

1.Class,method,object answer

The document provides an introduction to Java, covering fundamental concepts such as classes, methods, and objects. It includes theoretical questions and answers about Java's platform independence, open source, and differences between JDK, JRE, and JVM, as well as practical programming exercises demonstrating coding standards and object creation. Additionally, it outlines various Java features and comparisons with C++, along with sample projects and their implementations.

Uploaded by

kirthu ale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 18

Day1_Class,method,object

DAY1:
-------
1.Java Introduction
2.Class,Method,Object
3.Same package and Different package

QUESTIONS(Theory):
------------
1.What is platform independent?
ANS :
software can run on multiple operating systems and hardware platforms without
significant adjustments.
For example, if you create code on Windows and it can run on Linux, macOS, Unix, or
Solaris without any issues, then it is platform-independent.

2.What is open source?


ANS :
Open source is source code that is made freely available for possible modification
and redistribution.
For example, chrome, Firefox, Microsoft edge etc...

3.Difference between JDK,JRE,JVM?


ANS :
JVM:
----
It is used to compile and execute the code, which converts byte code into machine
code.
JVM provides basic java Function like memory management ,security ,garbage
collection, etc...
It can execute the java program line by line. Therefore ,it is also known as
Interpreter.
JIT compiler is used to convert byte code into machine code.

JRE:
----

It has supporting class files and libraries along JVM

JDK
----

It is Java Development Kit.


It has bundle of software tools along with JRE and JVM.
JDK is essential to develop or run java.

4.why we go for java?


ANS :
widely used high-level programming language
easy to learn and reliable.

5.What is the latest version of JDK and which version you are using in your
project?
ANS :
latest version of JDK Version 23 and java 11 version using in our project.

6.What is the latest version of eclipse and which version you are using in your
project?
ANS :
latest version of eclipse 2023 and 2023 version you are using in your project

7.Difference between C++ and java?

Feature C++
Java
1.Compilation Compiled directly into machine code.
Compiled into bytecode and then interpreted by JVM.
2.Syntax Syntax is closer to low-level languages like Assembly and
C. Syntax is closer to high-level languages like Python and
Ruby.
3.Object-Oriented
Programming Supports both procedural and object-oriented programming.
Purely object-oriented programming language.
4.Memory Management Has manual memory management through pointers.
Has automatic memory management through garbage collection.
5.Performance Faster performance due to direct machine code
execution. Slower performance due to bytecode
interpretation.
6.Template Library Standard Template Library (STL) provides robust and
Java provides collection framework for data structures,
efficient implementation of data structures.
but not as efficient as STL in C++.
7.Platform Dependence Platform-dependent, need to be recompiled for
different systems. Platform-independent, runs on any system with
JVM installed.
8.Multiple Inheritance Supports multiple inheritance
Does not support multiple inheritance, uses interface to achieve

similar functionality.

8.Features of java?
ANS :
Simple
Object-Oriented
Portable
Platform independent
Secured
Robust
Architecture neutral
Interpreted
High Performance
Multithreaded
Distributed
Dynamic

9.What type of tool you are using in your project to execute java?
ANS :
Eclipse. Eclipse is a popular ,open Source (IDE) primarily used for Java
programming.

10.Difference between class, method, object?


ANS :
Class- it is blueprint or logical template of an object.
it is consist of variable and method
which share the common properties
Object- instance(copy)of the class
memory creator to an object at runtime
Method - it is block of code
it is used to reuse the code
it is execute only when it is called

11.Where object stores?


ANS:
Object stores in class

12.How to access one class method in to another package in different package?


ANS :
To access one class method in to another package in different package using the
import syntax coding
EX: import com.tcs.naming.MyFirstClass;//import syntax

13.Coding standard to create project, class, method, package and object ?


ANS:
PROJECT-> file-new-javaproject

PACKAGE-> myfirstproject-src-rightclick-new-package
EX: package com.tcs.differentpackage;

CLASS -> myfirstproject-src-package-rightclick-new-class


EX:public class Sample2 {//new class
}

METHOD -> public void methodname(){ //method


}
public static void main(String[] args) { // main method
}

OBJECT -> class name reference name = new class name


EX: kiruthiga sample = new kiruthiga ();

14.What gives Java it's "write once and run anywhere" nature?
ANS:
Byte code 0s,1s

QUESTIONS(Programs):
-----------------
QUESTION 1:
------------
Project :EmployeeDetails
Package :org.emp
Class :Employee
Methods :empId(),empName(),empDob(),empPhone(),empEmail(),empAddress()

Description:
Create an object for employee class and call above methods also follow the all
coding standards.

ANSWER:

package org.emp;

public class Employee {


public void empId(){ //method syntax
System.out.println("Employee Id : 130799");
}
public void empName() {
System.out.println("Employee Name : Kiruthiga");
}
public void empDob() {
System.out.println("Employee Dob : 20-10-1997");
}
public void empPhone() {
System.out.println("Employee Phone : 8682939405");
}
public void empEmail() {
System.out.println("Employee Email :[email protected]");
}
public void empAddress() {
System.out.println("Employee Address : Chennai");
}

public static void main(String[] args) {


Employee emp = new Employee(); //object syntax
emp.empId(); // calling method syntax
emp.empName();
emp.empDob();
emp.empPhone();
emp.empEmail();
emp.empAddress();
}
}

QUESTION 2:
-------------
Project :Al-RightAddress
Package :org.add
Class :Al-RightTech
Methods :Al-RightOmr(),Al-RightAdayar(),Al-RightTambaram(),Al-
RightVelacherry(),Al-RightAnnaNagar()

Description:
Create an object for Al-RightTech class and call above methods also follow the all
coding standards.

ANSWER:

package org.add;

public class AlRightTech {

public void AlRightOmr() { //method syntax


System.out.println("foodcourt");
}
public void AlRightAdayar() {
System.out.println("a2b");
}
public void AlRightTambaram() {
System.out.println("MCC");
}
public void AlRightVelacherry(){
System.out.println("mall");
}
public void AlRightAnnaNagar() {
System.out.println("park");
}
public static void main(String[] args) {
AlRightTech al = new AlRightTech(); //object syntax
al.AlRightOmr(); // calling method syntax
al.AlRightAdayar();
al.AlRightTambaram();
al.AlRightVelacherry();
al.AlRightAnnaNagar();

}
}

QUESTION 3:
------------
Project :CompanyDetails
Package :org.company
Class :CompanyInfo
Methods :companyName(),companyId(),companyAddress()

Description:
Create an object for CompanyDetails class and call above methods also follow the
all coding standards.

ANSWER:

//Create an object for CompanyDetails class and call above methods also follow the
all coding standards.

package org.company;

public class CompanyInfo {

public void companyId(){ //method syntax


System.out.println("Company Id : 130799");
}
public void companyName() {
System.out.println("Company Name : AiiTE");
}
public void companyAddress() {
System.out.println("Company Address : Chennai");
}

public static void main(String[] args) {


CompanyInfo comp = new CompanyInfo(); //object syntax
comp.companyId();
comp.companyName();
comp.companyAddress();
}
}

QUESTION 4:
-----------
Project :MyPhone
Package :org.phone
Class :PhoneInfo
Methods :phoneName(),phoneimeiNum(),Camera(),storage(),osName()

Description:
Create an object for PhoneInfo class and call above methods also follow the all
coding standards.

ANSWER:

package org.phone;

public class PhoneInfo {

public void phoneName() {


System.out.println("Phone Name : APPLE");
}
public void phoneimeiNum(){ //method syntax
System.out.println("Phone Imei Num : 130799");
}
public void camera() {
System.out.println("Camera : 24 pixcel");
}
public void storage() {
System.out.println("Storage : 128GB");
}
public void osName() {
System.out.println("OsName : version 2.0");
}

public static void main(String[] args) {


PhoneInfo ph = new PhoneInfo(); //object syntax
ph.phoneName();
ph.phoneimeiNum();
ph.camera();
ph.storage();
ph.osName();
}

QUESTION 5:
------------
Project :LanguageDetails
Package :org.lang

Class :LanguageInfo
Methods :tamilLanguage(),englishLanguage(),hindiLanguage()
Class :StateDetails
Methods :southIndia(),northIndia()

Description:
Create an object for LanguageInfo and StateDetails inside the StateDetails class
call both classes methods also follow the all coding standards.

ANSWER:

LanguageInfo
---------------

package org.lang;

public class LanguageInfo {

public void tamilLanguage(){


System.out.println("tamil");
}
public void englishLanguage(){
System.out.println("english");
}
public void hindiLanguage(){
System.out.println("hindi");
}

StateDetails
-------------

package org.lang;

public class StateDetails {

public void southIndia(){


System.out.println("meals");
}
public void northIndia(){
System.out.println("rotti");
}

public static void main(String[] args) {


StateDetails sta = new StateDetails();
sta.southIndia();
sta.northIndia();
LanguageInfo lang =new LanguageInfo();
lang.tamilLanguage();
lang.englishLanguage();
lang.hindiLanguage();
}
}

QUESTION 6:
-----------
Project :EmployeeInformation
Package :org.emp
Class :Employee
Methods :empName()

Package :org.company
Class :Company
Methods :companyName()

Package :org.client
Class :Client
Methods :clientName()

Package :org.project
Class :Project
Methods :projectName()

Description:
Create an object for all 4 classes inside the Employee class and call all classes
methods also follow the all coding standards.

ANSWERS:
package org.emp;

public class Employee {


public void empName() {
System.out.println("Employee Name : Kiruthiga");
}
}

------------------------------

package org.company;

public class Company {

public void companyName() {


System.out.println("Company Name : AiiTE");
}
}

------------------------------

package org.client;

public class Client {

public void clinetName() {


System.out.println("Clinet Name : kiruthiga");
}

}
---------------------------------
package org.project;

public class Project {

public void projectName() {


System.out.println("Project Name : JAVA");
}
}
------------------------------

//Create an object for all 4 classes inside the Employee class and call all
classes methods
//also follow the all coding standards.

package org.emp;
import org.company.Company;
import org.client.Client;
import org.project.Project;

public class Employee {


public void empName() {
System.out.println("Employee Name : Kiruthiga");
}
public static void main(String[] args) {
Employee em = new Employee();
em.empName();
Company cm = new Company();
cm.companyName();
Client cl = new Client();
cl.clinetName();
Project pro = new Project();
pro.projectName();
}

QUESTION 7:
-------------
Project :PhoneDetails
Package :org.phone
Class :ExternalStorage
Methods :size()

Class :InternalStorage
Methods :processorName(),ramSize()

Description:
Create an object for ExternalStorage and InternalStorage inside the InternalStorage
class and call both classes methods also follow the all coding standards.

ANSWER:

package org.phone;

public class ExternalStorage {

public void size() {


System.out.println("Size : 128gb");
}
}

---------------------------

package org.phone;

public class InternalStorage {

public void processorName() {


System.out.println("Processor Name : OPPO");
}
public void ramSize() {
System.out.println("Ram Size : 128gb");
}
}

-----------------------------

package org.phone;

public class InternalStorage {

public void processorName() {


System.out.println("Processor Name : OPPO");
}
public void ramSize() {
System.out.println("Ram Size : 128gb");
}
public static void main(String[] args) {
ExternalStorage ex = new ExternalStorage();
ex.size();
InternalStorage in = new InternalStorage();
in.processorName();
in.ramSize();
}
}

QUESTION 8:
------------
Project :CollegeInformation
Package :org.college
Class :College
Methods :collegeName(),collegeCode(),collegeRank()

Class :Student
Methods :studentName(),studentDept(),studentId()

Class :Hostel
Methods :hostelName()

Class :Dept
Methods :deptName()
Description:
Create an object for all 4 classes inside the College class and call all classes
methods also follow the all coding standards.

ANSWER:

package org.college;

public class College {


public void collegeName() {
System.out.println("College Name : MCC");
}
public void collegeCode() {
System.out.println("College Code : 232");
}
public void collegeRank() {
System.out.println("College Rank : 1");
}

------------------------------
package org.college;

public class Student {


public void studentName() {
System.out.println("Student Name : kiruthiga");
}
public void studenteCode() {
System.out.println("Student Code : CD23");
}
public void studentId() {
System.out.println("Student ID : 2131");
}

------------------------------

package org.college;

public class Hostel {


public void hosteName() {
System.out.println("College Name : MCC hostel");
}
}

---------------------------------
package org.college;

public class Dept {

public void deptName() {


System.out.println("DEPT Name : Computer");
}
}
------------------------------

//Create an object for all 4 classes inside the Employee class and call all
classes methods
//also follow the all coding standards.

package org.college;

public class College {


public void collegeName() {
System.out.println("College Name : MCC");
}
public void collegeCode() {
System.out.println("College Code : 232");
}
public void collegeRank() {
System.out.println("College Rank : 1");
}
public static void main(String[] args) {
College co =new College();
co.collegeName();
co.collegeCode();
co.collegeRank();
Student st = new Student();
st.studentName();
st.studenteCode();
st.studentId();
Hostel ho = new Hostel();
ho.hosteName();
Dept de = new Dept();
de.deptName();

QUESTION 9:
------------
Project :VehicleInformation
Package :org.allvehicle
Class :Vehicle
Methods :VehicleNecessery()

Package :org.twowheeler
Class :TwoWheller
Methods :bike(),cycle()

Package :org.threewheeler
Class :ThreeWheeler
Methods :Auto()

Package :org.fourwheeler
Class :FourWheeler
Methods :car(),bus(),lorry()
Description:
Create an object for all 4 classes inside the Vehicle class and call all classes
methods also follow the all coding standards.

ANSWER:

package org.allvehicle;

public class Vehicle {

public void VehicleNecessery() {


System.out.println("Vehicle Necessery : ALL");
}

}
----------------------------------------

package org.twowheeler;

public class TwoWheller {


public void bike() {
System.out.println("Bike : yamaha");
}
public void cycle() {
System.out.println("Cycle : ladybird");
}

------------------------------------------

package org.threewheeler;

public class ThreeWheeler {


public void auto() {
System.out.println("Auto : Mahindra");
}

----------------------------------------------

package org.fourwheeler;

public class FourWheeler {


public void car() {
System.out.println("Car : MG");
}
public void bus() {
System.out.println("Bus : Benz");
}
public void lorry() {
System.out.println("Lorry : Tata");
}
}
---------------------------------------------------

//Create an object for all 4 classes inside the Vehicle class and
//call all classes methods also follow the all coding standards.

package org.allvehicle;
import org.twowheeler.TwoWheller;
import org.threewheeler.ThreeWheeler;
import org.fourwheeler.FourWheeler;

public class Vehicle {

public void VehicleNecessery() {


System.out.println("Vehicle Necessery : ALL");
}
public static void main(String[] args) {

Vehicle ve = new Vehicle();


ve.VehicleNecessery();
TwoWheller tw = new TwoWheller();
tw.bike();
tw.cycle();
ThreeWheeler thr = new ThreeWheeler();
thr.auto();
FourWheeler fo = new FourWheeler();
fo.bus();
fo.car();
fo.lorry();

}
}

QUESTION 10:
--------------
Project :TransportInformation
Package :org.transport
Class :Transport
Methods :TransportForm

Package :org.road
Class :Road
Methods :bike(),cycle(),bus(),car()

Package :org.air
Class :Air
Methods :aeroPlane(),heliCopter()

Package :org.water
Class :Water
Methods :boat(),ship()
Description:
Create an object for all 4 classes inside the Transport class and call all classes
methods also follow the all coding standards.

ANSWER:

package org.transport;

public class Transport {


public void transportForm() {
System.out.println("TransportForm : heavy load");
}
}
-----------------------------------------
package org.road;

public class Road {


public void bike() {
System.out.println("Bike : fascino");
}
public void cycle() {
System.out.println("Cycle : lady bird");
}
public void bus() {
System.out.println("Bus : red bus");
}
public void car() {
System.out.println("Car : BMW");
}

}
---------------------------------------------------

package org.air;

public class Air {


public void aeroPlane() {
System.out.println("AeroPlane : Indigo");
}
public void heliCopter() {
System.out.println("HeliCopter : Military");
}

}
---------------------------------------------------

package org.water;

public class Water {

public void boat() {


System.out.println("boat : Fisher man");
}
public void ship() {
System.out.println("Ship : Captan");
}
}
--------------------------------------------------

//Create an object for all 4 classes inside the Transport class and call all
classes methods also follow the all coding standards.

package org.transport;
import org.road.Road;
import org.air.Air;
import org.water.Water;

public class Transport {


public void transportForm() {
System.out.println("TransportForm : heavy load");
}
public static void main(String[] args) {

Transport tra = new Transport();


tra.transportForm();
Road ro = new Road();
ro.bike();
ro.bus();
ro.car();
ro.cycle();
Air air = new Air();
air.aeroPlane();
air.heliCopter();
Water wat = new Water();
wat.boat();
wat.ship();

}
}

---------------------

QUESTION 11:
--------------
Project :NetworkInformation
Package :org.network
Class :Wifi
Methods :wifiName()

Class :MobileData
Methods :dataName()

Class :Lan
Methods :lanName()

Class :Wireless
Methods :modamName()

Description:
Create an object for all 4 classes inside the Wifi class and call all classes
methods also follow the all coding standards.

ANSWER:

package org.network;

public class Wifi {


public void wifiName() {
System.out.println("WifiName : Airtel");
}
}

---------------------------------------------------

package org.network;

public class MobileData {


public void mobileData() {
System.out.println("MobileData : 15MB");
}
}

---------------------------------------------

package org.network;

public class Lan {


public void lanName() {
System.out.println("LanName : Hathway");
}
}

-------------------------------------------

package org.network;

public class Wireless {


public void modamName() {
System.out.println("ModamName : JIO");
}
}

----------------------------------------------

//Create an object for all 4 classes inside the Wifi class and
//call all classes methods also follow the all coding standards.

package org.network;

public class Wifi {


public void wifiName() {
System.out.println("WifiName : Airtel");
}
public static void main(String[] args) {
Wifi wi = new Wifi();
wi.wifiName();
MobileData mo = new MobileData();
mo.mobileData();
Lan lan = new Lan();
lan.lanName();
Wireless wir = new Wireless();
wir.modamName();
}
}
}

You might also like