SlideShare ist ein Scribd-Unternehmen logo
1 von 2
Bansilal Ramnath Agarwal Charitable Trust’s
                Vishwakarma Institute of Technology, Pune. 37

                     Principles of Programming Languages
                                CS 20105 – SE – E

                              Home Assignment 3

Assignment Date: 15th March 2012              Submission Date: 20th March 2012

Answer all 8 questions:
1. Write a complete Java code to print “Home Assignment 3” on console.
Specifically mention the file name and extension and the steps to compile and
execute your code.

2. What will be the output of the following code?
//Room.java
public class Room {
       int i;
       public Room(int i) {
              this.i = i;
       }
       public void print() {
              System.out.println(i);
       }
}
//TestRoom.java
public class TestRoom {
       public static void main(String[] args) {
              Room r = new Room();
              r.print();
       }
}

3. Look at the following organization of classes:
- there are two packages, “vit.cse.se” and “vit.cse.fe”
- in “vit.cse.se” there are two classes, A and B
- in “vit.cse.fe” there are two classes, C and D
- class A has
        - a private field: private int i;

                                                                      Page 1 of 2
- another field: int j;
        - a protected field: protected int k;
        - a public field: public int m;
- class D extends class A
Based on the above description, which of the following statements are true in
Java:
    a) Any method defined in class A can access any of the fields i, j, k and m
    b) Any method defined in class A can access any of the fields j, k and m but
        not i since i is private
    c) Any method in class C can access m, k and j of A
    d) Any method in class B can access m and j in A
    e) Any method in class D can only access m of A since that is the only public
        field in A

4. Write complete Java code for the following classes:
- class Vehicle
- class TwoWheeler
- class FourWheeler
- class Scooter
- class Car
Use inheritance and/or composition wherever appropriate. For fields and
methods, use common sense and make whatever assumptions necessary. Also
mention what are the different types of inheritance you have used in this
example.

5. Explain the signature of “main”method in Java.

6. True or False
a) Java supports multiple inheritance
b) Abstract class can contain some method implementations
c) Interface can be instantiated
d) A class can “extend” multiple classes
e) A class can “implement” multiple interfaces

7. What is a “user defined exception”? Write Java code for defining a user-
defined exception and a demo code for throwing and catching your exception.

8. Give an example each of multi-level inheritance and hierarchical inheritance.




                                                                        Page 2 of 2

Weitere ähnliche Inhalte

Was ist angesagt?

Interfaces c#
Interfaces c#Interfaces c#
Interfaces c#Nipam Medhi
 
Module 11 : Inheritance
Module 11 : InheritanceModule 11 : Inheritance
Module 11 : InheritancePrem Kumar Badri
 
interface in c#
interface in c#interface in c#
interface in c#Deepti Pillai
 
Binding,interface,abstarct class
Binding,interface,abstarct classBinding,interface,abstarct class
Binding,interface,abstarct classvishal choudhary
 
Java interface
Java interfaceJava interface
Java interfaceArati Gadgil
 
MX Server is my friend
MX Server is my friendMX Server is my friend
MX Server is my friendGabriel Daty
 
Java interface
Java interfaceJava interface
Java interfaceBHUVIJAYAVELU
 
What are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | EdurekaWhat are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | EdurekaEdureka!
 
Interfaces and abstract classes
Interfaces and abstract classesInterfaces and abstract classes
Interfaces and abstract classesAKANSH SINGHAL
 
Abstract & Interface
Abstract & InterfaceAbstract & Interface
Abstract & InterfaceLinh LĂŞ
 
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...Simplilearn
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++Rajes Wari
 

Was ist angesagt? (18)

Interfaces c#
Interfaces c#Interfaces c#
Interfaces c#
 
Module 11 : Inheritance
Module 11 : InheritanceModule 11 : Inheritance
Module 11 : Inheritance
 
interface in c#
interface in c#interface in c#
interface in c#
 
Interface &packages
Interface &packagesInterface &packages
Interface &packages
 
Binding,interface,abstarct class
Binding,interface,abstarct classBinding,interface,abstarct class
Binding,interface,abstarct class
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
Java interface
Java interfaceJava interface
Java interface
 
MX Server is my friend
MX Server is my friendMX Server is my friend
MX Server is my friend
 
Java interface
Java interfaceJava interface
Java interface
 
What are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | EdurekaWhat are Abstract Classes in Java | Edureka
What are Abstract Classes in Java | Edureka
 
Interfaces and abstract classes
Interfaces and abstract classesInterfaces and abstract classes
Interfaces and abstract classes
 
Interface
InterfaceInterface
Interface
 
ICOM4015 CIIC4010 Exam Review #1
ICOM4015 CIIC4010 Exam Review #1 ICOM4015 CIIC4010 Exam Review #1
ICOM4015 CIIC4010 Exam Review #1
 
Abstract & Interface
Abstract & InterfaceAbstract & Interface
Abstract & Interface
 
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...
C# Interface | Interfaces In C# | C# Interfaces Explained | C# Tutorial For B...
 
Interface
InterfaceInterface
Interface
 
Object oriented programming c++
Object oriented programming c++Object oriented programming c++
Object oriented programming c++
 

Andere mochten auch

Cadete b
Cadete bCadete b
Cadete bfbcat
 
Digital media FBC
Digital media FBCDigital media FBC
Digital media FBCrksholgings
 
Windows 8 adan fr
Windows 8 adan frWindows 8 adan fr
Windows 8 adan frAdan Figueroa
 
2bachillerato2evaluacion
2bachillerato2evaluacion2bachillerato2evaluacion
2bachillerato2evaluacionantonioamayatena
 
Love Radio
Love RadioLove Radio
Love RadiosaidWot
 

Andere mochten auch (7)

Cadete b
Cadete bCadete b
Cadete b
 
Digital media FBC
Digital media FBCDigital media FBC
Digital media FBC
 
Un blog
Un blogUn blog
Un blog
 
Caratula
CaratulaCaratula
Caratula
 
Windows 8 adan fr
Windows 8 adan frWindows 8 adan fr
Windows 8 adan fr
 
2bachillerato2evaluacion
2bachillerato2evaluacion2bachillerato2evaluacion
2bachillerato2evaluacion
 
Love Radio
Love RadioLove Radio
Love Radio
 

Ă„hnlich wie Ppl home assignment_unit3

C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...yazad dumasia
 
Introduction to object oriented programming concepts
Introduction to object oriented programming conceptsIntroduction to object oriented programming concepts
Introduction to object oriented programming conceptsGanesh Karthik
 
T1
T1T1
T1lksoo
 
Java Programming.pdf
Java Programming.pdfJava Programming.pdf
Java Programming.pdfRavinderKSingla
 
CS244 _Lec8_Generics_innerclasses_Lambda.pptx
CS244 _Lec8_Generics_innerclasses_Lambda.pptxCS244 _Lec8_Generics_innerclasses_Lambda.pptx
CS244 _Lec8_Generics_innerclasses_Lambda.pptxNadeemEzat
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using ReflectionGanesh Samarthyam
 
Inheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ optInheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ optdeepakskb2013
 
csharp_dotnet_adnanreza.pptx
csharp_dotnet_adnanreza.pptxcsharp_dotnet_adnanreza.pptx
csharp_dotnet_adnanreza.pptxPoornima E.G.
 
java basic .pdf
java basic .pdfjava basic .pdf
java basic .pdfSatish More
 
ITTutor Advanced Java (1).pptx
ITTutor Advanced Java (1).pptxITTutor Advanced Java (1).pptx
ITTutor Advanced Java (1).pptxkristinatemen
 
Chapter 7:Understanding Class Inheritance
Chapter 7:Understanding Class InheritanceChapter 7:Understanding Class Inheritance
Chapter 7:Understanding Class InheritanceIt Academy
 
E4
E4E4
E4lksoo
 
chapter-10-inheritance.pdf
chapter-10-inheritance.pdfchapter-10-inheritance.pdf
chapter-10-inheritance.pdfstudy material
 
Exception handling and packages.pdf
Exception handling and packages.pdfException handling and packages.pdf
Exception handling and packages.pdfKp Sharma
 
Bca1020 programming in c
Bca1020  programming in cBca1020  programming in c
Bca1020 programming in csmumbahelp
 

Ă„hnlich wie Ppl home assignment_unit3 (20)

C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
 
Java sessionnotes
Java sessionnotesJava sessionnotes
Java sessionnotes
 
Introduction to object oriented programming concepts
Introduction to object oriented programming conceptsIntroduction to object oriented programming concepts
Introduction to object oriented programming concepts
 
T1
T1T1
T1
 
Java Programming.pdf
Java Programming.pdfJava Programming.pdf
Java Programming.pdf
 
CS244 _Lec8_Generics_innerclasses_Lambda.pptx
CS244 _Lec8_Generics_innerclasses_Lambda.pptxCS244 _Lec8_Generics_innerclasses_Lambda.pptx
CS244 _Lec8_Generics_innerclasses_Lambda.pptx
 
DAY_1.1.pptx
DAY_1.1.pptxDAY_1.1.pptx
DAY_1.1.pptx
 
Understanding And Using Reflection
Understanding And Using ReflectionUnderstanding And Using Reflection
Understanding And Using Reflection
 
Inheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ optInheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ opt
 
csharp_dotnet_adnanreza.pptx
csharp_dotnet_adnanreza.pptxcsharp_dotnet_adnanreza.pptx
csharp_dotnet_adnanreza.pptx
 
java basic .pdf
java basic .pdfjava basic .pdf
java basic .pdf
 
CHAPTER 3 part1.pdf
CHAPTER 3 part1.pdfCHAPTER 3 part1.pdf
CHAPTER 3 part1.pdf
 
Quiz1solt (2)
Quiz1solt (2)Quiz1solt (2)
Quiz1solt (2)
 
ITTutor Advanced Java (1).pptx
ITTutor Advanced Java (1).pptxITTutor Advanced Java (1).pptx
ITTutor Advanced Java (1).pptx
 
Ganesh groups
Ganesh groupsGanesh groups
Ganesh groups
 
Chapter 7:Understanding Class Inheritance
Chapter 7:Understanding Class InheritanceChapter 7:Understanding Class Inheritance
Chapter 7:Understanding Class Inheritance
 
E4
E4E4
E4
 
chapter-10-inheritance.pdf
chapter-10-inheritance.pdfchapter-10-inheritance.pdf
chapter-10-inheritance.pdf
 
Exception handling and packages.pdf
Exception handling and packages.pdfException handling and packages.pdf
Exception handling and packages.pdf
 
Bca1020 programming in c
Bca1020  programming in cBca1020  programming in c
Bca1020 programming in c
 

Mehr von Akshay Nagpurkar

Dcunit4 transmission media
Dcunit4 transmission mediaDcunit4 transmission media
Dcunit4 transmission mediaAkshay Nagpurkar
 
Ppl for students unit 4 and 5
Ppl for students unit 4 and 5Ppl for students unit 4 and 5
Ppl for students unit 4 and 5Akshay Nagpurkar
 
Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3Akshay Nagpurkar
 
Ppl for students unit 4 and 5
Ppl for students unit 4 and 5Ppl for students unit 4 and 5
Ppl for students unit 4 and 5Akshay Nagpurkar
 
Ppl home assignment_unit4
Ppl home assignment_unit4Ppl home assignment_unit4
Ppl home assignment_unit4Akshay Nagpurkar
 
Ppl home assignment_unit5
Ppl home assignment_unit5Ppl home assignment_unit5
Ppl home assignment_unit5Akshay Nagpurkar
 
Pcm pulse codemodulation-2
Pcm pulse codemodulation-2Pcm pulse codemodulation-2
Pcm pulse codemodulation-2Akshay Nagpurkar
 
Modulation techniq of modem
Modulation techniq of modemModulation techniq of modem
Modulation techniq of modemAkshay Nagpurkar
 
Ppl home assignment_unit2
Ppl home assignment_unit2Ppl home assignment_unit2
Ppl home assignment_unit2Akshay Nagpurkar
 
Ppl home assignment_unit1
Ppl home assignment_unit1Ppl home assignment_unit1
Ppl home assignment_unit1Akshay Nagpurkar
 

Mehr von Akshay Nagpurkar (20)

4.osi model
4.osi model4.osi model
4.osi model
 
L6 mecse ncc
L6 mecse nccL6 mecse ncc
L6 mecse ncc
 
Tcp ip
Tcp ipTcp ip
Tcp ip
 
1 ip address
1 ip address1 ip address
1 ip address
 
1.network topology
1.network topology1.network topology
1.network topology
 
1.lan man wan
1.lan man wan1.lan man wan
1.lan man wan
 
Dcunit4 transmission media
Dcunit4 transmission mediaDcunit4 transmission media
Dcunit4 transmission media
 
Ppl for students unit 4 and 5
Ppl for students unit 4 and 5Ppl for students unit 4 and 5
Ppl for students unit 4 and 5
 
Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3Ppl for students unit 1,2 and 3
Ppl for students unit 1,2 and 3
 
Ppl for students unit 4 and 5
Ppl for students unit 4 and 5Ppl for students unit 4 and 5
Ppl for students unit 4 and 5
 
234 rb trees2x2
234 rb trees2x2234 rb trees2x2
234 rb trees2x2
 
Ppl home assignment_unit4
Ppl home assignment_unit4Ppl home assignment_unit4
Ppl home assignment_unit4
 
Ppl home assignment_unit5
Ppl home assignment_unit5Ppl home assignment_unit5
Ppl home assignment_unit5
 
3 multiplexing-wdm
3 multiplexing-wdm3 multiplexing-wdm
3 multiplexing-wdm
 
2 multiplexing
2 multiplexing2 multiplexing
2 multiplexing
 
1 multiplexing
1 multiplexing1 multiplexing
1 multiplexing
 
Pcm pulse codemodulation-2
Pcm pulse codemodulation-2Pcm pulse codemodulation-2
Pcm pulse codemodulation-2
 
Modulation techniq of modem
Modulation techniq of modemModulation techniq of modem
Modulation techniq of modem
 
Ppl home assignment_unit2
Ppl home assignment_unit2Ppl home assignment_unit2
Ppl home assignment_unit2
 
Ppl home assignment_unit1
Ppl home assignment_unit1Ppl home assignment_unit1
Ppl home assignment_unit1
 

KĂĽrzlich hochgeladen

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
WhatsApp 9892124323 âś“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 âś“Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 âś“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 âś“Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 

KĂĽrzlich hochgeladen (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
WhatsApp 9892124323 âś“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 âś“Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 âś“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 âś“Call Girls In Kalyan ( Mumbai ) secure service
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 

Ppl home assignment_unit3

  • 1. Bansilal Ramnath Agarwal Charitable Trust’s Vishwakarma Institute of Technology, Pune. 37 Principles of Programming Languages CS 20105 – SE – E Home Assignment 3 Assignment Date: 15th March 2012 Submission Date: 20th March 2012 Answer all 8 questions: 1. Write a complete Java code to print “Home Assignment 3” on console. Specifically mention the file name and extension and the steps to compile and execute your code. 2. What will be the output of the following code? //Room.java public class Room { int i; public Room(int i) { this.i = i; } public void print() { System.out.println(i); } } //TestRoom.java public class TestRoom { public static void main(String[] args) { Room r = new Room(); r.print(); } } 3. Look at the following organization of classes: - there are two packages, “vit.cse.se” and “vit.cse.fe” - in “vit.cse.se” there are two classes, A and B - in “vit.cse.fe” there are two classes, C and D - class A has - a private field: private int i; Page 1 of 2
  • 2. - another field: int j; - a protected field: protected int k; - a public field: public int m; - class D extends class A Based on the above description, which of the following statements are true in Java: a) Any method defined in class A can access any of the fields i, j, k and m b) Any method defined in class A can access any of the fields j, k and m but not i since i is private c) Any method in class C can access m, k and j of A d) Any method in class B can access m and j in A e) Any method in class D can only access m of A since that is the only public field in A 4. Write complete Java code for the following classes: - class Vehicle - class TwoWheeler - class FourWheeler - class Scooter - class Car Use inheritance and/or composition wherever appropriate. For fields and methods, use common sense and make whatever assumptions necessary. Also mention what are the different types of inheritance you have used in this example. 5. Explain the signature of “main”method in Java. 6. True or False a) Java supports multiple inheritance b) Abstract class can contain some method implementations c) Interface can be instantiated d) A class can “extend” multiple classes e) A class can “implement” multiple interfaces 7. What is a “user defined exception”? Write Java code for defining a user- defined exception and a demo code for throwing and catching your exception. 8. Give an example each of multi-level inheritance and hierarchical inheritance. Page 2 of 2