Location via proxy:
[ UP ]
[Report a bug]
[Manage cookies]
No cookies
No scripts
No ads
No referrer
Show this form
Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
7 views
Java assignment-1
Java important questions for semester exams for 3rd semester
Uploaded by
Johnny GAMER
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Java assignment-1 For Later
Download
Save
Save Java assignment-1 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
7 views
Java assignment-1
Java important questions for semester exams for 3rd semester
Uploaded by
Johnny GAMER
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Java assignment-1 For Later
Carousel Previous
Carousel Next
Save
Save Java assignment-1 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 17
Search
Fullscreen
r Thursday ABI-aH ASSIGNMENT - 03 =— == => v Define inheritance and éxplato the digevert te 4 iphentanee yaith relevant examples « 7% aa into Acquiring the propertiee from one class (parent class) Gub class (child etass) ts caned Sohenitan ce” ~ Parent class 18 also called super class ov base class and child class ts called as a Sub-class OF deived class - ‘Type 4 Tnheritanee ! \ Single - level “fin evitanee | sub class Wheo a class inherits propatis from another class then iF is called at Single « level ~inhentanes « $x! class Animal L void eat C) t Syetern out : painelo (“eating”) ; 42class Dog extends Anima) t void bavk() c Sysern out priotto ("barking"); | s J Class Test Tohentanee t public static void main ( String CIarqs) t Dog dz new Dog 0) 5, d+ baat 095 deat; y y. Output * barking eating. AY Mult level ~ Sheritance ? Class -C| | : | Wathen there {8 a chain of inh ertance , then it '¢ Known ag multi-level Tnhevtanee -Example! Class Animal t vod att) t System: out * print lo (“eating”); 3 Claes hog extends Animal t void barke) t System: cut: printto ("barking"); 4] 3 class Baby Dog extends Dog t vord sleep c s System sout print (ucteep”); x + Class Test Inhenitanee public static wid mai (String args C1) < Baby Dog bs new Baby Pog Oe b: sleepO)s b- bavk0); 5 y b- eat); 44 aput ut! Sleeping a barking eating, 37 Heivarehical = Level-Tnhevitanee: 9 two oF more classes Inherit King\e class then {4 ts Knoven whet as Herarchical -Level~ Mheitance - sxample class Animal eC void wat Cc) ic System + out + printlo (“eating”); 3 class Dog extends Anima) t void bark ¢) € Systern out “print lo (“'baaktng")5 y s ; class cat extends Anienal
out: prtatta (95: 4S); System out: pratty (°K! 94K); fot Colthy 4 System out printia ‘ita 3 class main class < public stare void mai (Sting Ca8qs) Bb » new @ (1421395 br add HO 50 NN eeebraddikey; * 3 af gurput' (it}>)3 th Ki3 (ab t4 y. 8) Super 1 used {p invoke ‘gupe? clase hittodl! ~hheo parent class method and child dass method names are damt {0 otherusords the method ts overiden - - class Animal 4 votd eat ©) t System - out: griatlo (rath animals can eat"); yord cat) L | | | 3 class Dog extends Animal System -out “pantlo (eating bread”) 5 iy void bak) 4 System: out priate (“basking ") 5 3 51 ee ae ee a ee ee| : 1 Void usorke ) 4 Super -catC) 5 Super barker; 3 Class main class t public State void mato (Sting args C3) ¢ Dog d+ new Dogt); d-soak 0); 4 Sutput AM animals can eat PP hwite a program yohich {mplemanés the usage oy JAVA method overiamg Tt te used 0 provide Specific implementation ya method that je alrady provided by its Super etoss » R te basteatty used for oun, time polyriophiem « class Bank v int getRate of Aoeerest 0) ¢ xetumn 0; a 82 —_—eeeeclass SOL extends Bank & fat get Rateop Tnterest (9 £ etn 8) ¥ s crass 1CtCl extends Bank ¢ int getRateof Loterest 69 ¢ vetunn F 5 s J Class AXIS extends Bank ¢ int get Rateog Taterest 9 £ retum 4) y 5 tlass Test 9 ¢ public statie void main (String CJ.axg8) ¢ SBI Se new SBI 0); Jere) | = nevo icteley, Axis az neva AXIS CO); Syston out: pret ("S01 Rate of Tateest °F S* get Rate of Jaterest) j Systeen- out’ prinetn (eter Rate af Interests” ¢ (gp tle eat oO); ; 53 ie ee ee eee eeni Systera out: print (“Axis Rate af Anterest 2" 4 age hate of ' LatorestO) 5 eY, Output! SB Rate of Tntorest ! 8 lerel Rate of tnterest | Anis kate &p gaterest Ty, 4 Define abshact classes and Lxplain the use oF abstract method, and classes sith velevant examples » ~ Abshact Classes! We aan digine a superclass that declares the ere of a given abshacton, usithout providing a Complete implementation af every method. ‘fhe gunaral form of a9 abstract dass typename Cpavameter - ist ) 5 ~ using abstact methods and classes! abstract class Figure € double dim 4! double dim 9 + Figure (double a, double b) t dim dea, dim 92, is, abshact double area C)5 f 6class Rectangle ortends Figure t Rectangle (double a, double b) ¢ Super (a,b) ‘ y double areal) System -out * printto (“Sherde Area for fastangle.”) 5 rebum diel din 25 ¥ 4 class Triangle extends Figure t Frangle (double a , double b) eC Supyr (arb oh x double areal) 3 aH Systern - out printlo ("Dneide Area for Triangu - )5 rear dim) aim] & ; ¥ A class Abstract Anat public static void mato (String CJargs) € /| Figure = new figure (10) 5 fettong tu o> co Rectang le (9:8); friangle £= new ‘Triangle (10,8 J; Figure fignet 5 a Pe OS eeAgr -r; ; System - out’ printlo ("Area te "4 gignep a7e0)3 figref et) : Syste out: prinélo (“Area is” a feguep ard); ¥ x Butput’ theide area for reciangle area is 45-60 Inside area for Trhangls aua '¢ 40°04. BY Depi tfine Tntegace by undustanding the relationship. betuown classes and jotexawe usith guitable example os ' Teteyace! In Java, an interjace fe a blue print of a class « FR has static conctants and abshact methods - ~ The liteaee in Java te a mechaniem to acheive abstraction. ~ Undastand yetatonship between classes and Interfaces! An jntexface ie defined much like a class -General foun of an interface ! access intaqace name t type final _— varname 4 = value) type Avaal _ varname 9 = value} 44ype Pinal — yasname N= value } ret “Aype method -name 4 (pavametor ~ list ) 5 Yeturn - type method- name 9 (parameter - 184 ) 5 , - Interface Sayable & Statice void say Louder (String meq) 4 System put pratlo (msg) 4 ¥ 3 public class Default Methods implemends Sayable € public static void main (Shing CJarqs) ¢ Sayable saylouder (“Hetloooo- Boe 5) x J. Output « Helloooo..-.. 57a” tiple foheritane, fn i 6 nite program ughich implements maul Tava by inteyaee - ode} Interface Sayable 4 default void say C) Say Something 0) 5 ¥ : Pavate void Saysomething () 4 ‘ F Syston out® priatlo (*Hello--- Sm private method”): Ss ee class private Tukuface Spleen ts Sayable i public stave vord main [ Sting CI 429s) L Sayable = neva Private Tkerface 095 S sayl); 5 4 Outpur! Hello... T'm private method n, 58
You might also like
1683044825934
PDF
No ratings yet
1683044825934
5 pages
JavaQbank V2
PDF
No ratings yet
JavaQbank V2
16 pages
Mod 3
PDF
No ratings yet
Mod 3
21 pages
Oop Concept
PDF
No ratings yet
Oop Concept
33 pages
Adobe Scan Nov 06, 2023
PDF
No ratings yet
Adobe Scan Nov 06, 2023
20 pages
Java Focused Short
PDF
No ratings yet
Java Focused Short
28 pages
Exam Java
PDF
No ratings yet
Exam Java
21 pages
Chapter Five
PDF
No ratings yet
Chapter Five
31 pages
Java
PDF
No ratings yet
Java
24 pages
Object-Oriented Programming With Java 7541-880
PDF
No ratings yet
Object-Oriented Programming With Java 7541-880
64 pages
Oops 03
PDF
No ratings yet
Oops 03
14 pages
Unit 3 - Relationships
PDF
No ratings yet
Unit 3 - Relationships
23 pages
Dashrath Nandan Java (Unit1) Notes - Alasso
PDF
No ratings yet
Dashrath Nandan Java (Unit1) Notes - Alasso
11 pages
UNIT:1 Þashath: A Pupiam
PDF
No ratings yet
UNIT:1 Þashath: A Pupiam
49 pages
Non Primitive Typecasting
PDF
No ratings yet
Non Primitive Typecasting
15 pages
Java A1
PDF
No ratings yet
Java A1
15 pages
Adobe Scan Jul 01, 2024
PDF
No ratings yet
Adobe Scan Jul 01, 2024
12 pages
12_Aruna_assignment 2 java
PDF
No ratings yet
12_Aruna_assignment 2 java
9 pages
Java Part 2
PDF
No ratings yet
Java Part 2
20 pages
OOP (Imp)
PDF
No ratings yet
OOP (Imp)
41 pages
Unit 3 - Programs
PDF
No ratings yet
Unit 3 - Programs
18 pages
Abstraction&Multiple Inheritance
PDF
No ratings yet
Abstraction&Multiple Inheritance
18 pages
Week 5
PDF
No ratings yet
Week 5
8 pages
Concept Programs - Docx 1
PDF
No ratings yet
Concept Programs - Docx 1
29 pages
Inheritance
PDF
No ratings yet
Inheritance
70 pages
DocScanner 30 Sept 2024 2 33 PM
PDF
No ratings yet
DocScanner 30 Sept 2024 2 33 PM
12 pages
CPP OOPS Module 5
PDF
No ratings yet
CPP OOPS Module 5
37 pages
Chapter 3 - Inheritance and Polymorphism
PDF
100% (1)
Chapter 3 - Inheritance and Polymorphism
37 pages
JAVA Development: Inheritance, Interfaces, Abstract, Polymorphism
PDF
No ratings yet
JAVA Development: Inheritance, Interfaces, Abstract, Polymorphism
44 pages
JavaProgramming_Lecture04
PDF
No ratings yet
JavaProgramming_Lecture04
25 pages
Java CheatSheet
PDF
No ratings yet
Java CheatSheet
5 pages
Oop Concept in Java
PDF
100% (1)
Oop Concept in Java
47 pages
Java
PDF
No ratings yet
Java
11 pages
Lecture 4.Part1
PDF
No ratings yet
Lecture 4.Part1
51 pages
Unit 5
PDF
No ratings yet
Unit 5
37 pages
Untitled document (1)
PDF
No ratings yet
Untitled document (1)
2 pages
BCS306A-module 3,4,5 3rd sem
PDF
No ratings yet
BCS306A-module 3,4,5 3rd sem
24 pages
Lab 05
PDF
No ratings yet
Lab 05
6 pages
1SG19IS043 - Karthik Bharadwaj.P - OOC
PDF
No ratings yet
1SG19IS043 - Karthik Bharadwaj.P - OOC
17 pages
OOPJ All 5 Units Ninad
PDF
No ratings yet
OOPJ All 5 Units Ninad
118 pages
Inheritance
PDF
No ratings yet
Inheritance
36 pages
C++@UNIT-IV
PDF
No ratings yet
C++@UNIT-IV
50 pages
Notes (27Sept2024(
PDF
No ratings yet
Notes (27Sept2024(
12 pages
JPR Question Bank_For_PTT1 (1)
PDF
No ratings yet
JPR Question Bank_For_PTT1 (1)
7 pages
Elective
PDF
No ratings yet
Elective
27 pages
135 Week 8
PDF
No ratings yet
135 Week 8
56 pages
Unit 2 Java
PDF
No ratings yet
Unit 2 Java
8 pages
C++ Assignment 2
PDF
No ratings yet
C++ Assignment 2
27 pages
Chap 11
PDF
No ratings yet
Chap 11
50 pages
Object and Class Example: Main Within The Class
PDF
No ratings yet
Object and Class Example: Main Within The Class
17 pages
CHAPTER 3 Inheritance
PDF
No ratings yet
CHAPTER 3 Inheritance
44 pages
Unit 2 Java
PDF
No ratings yet
Unit 2 Java
13 pages
Inheritance 1
PDF
No ratings yet
Inheritance 1
42 pages
95712C Lecture Notes Wednesday, September 29, 2004: 1. Stringtokenizer Class
PDF
No ratings yet
95712C Lecture Notes Wednesday, September 29, 2004: 1. Stringtokenizer Class
7 pages
la practice
PDF
No ratings yet
la practice
25 pages
CSC584 Enterprise Programming: Chapter 1 - Review of Object-Oriented Programming
PDF
No ratings yet
CSC584 Enterprise Programming: Chapter 1 - Review of Object-Oriented Programming
54 pages
MCA Java Programming 04(2)
PDF
No ratings yet
MCA Java Programming 04(2)
20 pages
PPT
PDF
No ratings yet
PPT
36 pages
SCR
PDF
No ratings yet
SCR
27 pages
OS-assignment-1
PDF
No ratings yet
OS-assignment-1
1 page
SFH Previous Year Question Paper
PDF
100% (2)
SFH Previous Year Question Paper
9 pages
Program11
PDF
No ratings yet
Program11
9 pages
CAED Lab Prac.
PDF
No ratings yet
CAED Lab Prac.
1 page
Indian Constitution 2
PDF
No ratings yet
Indian Constitution 2
8 pages
Python Basics
PDF
No ratings yet
Python Basics
23 pages
Module-1 Sensors
PDF
No ratings yet
Module-1 Sensors
31 pages
Moment of Inertia
PDF
No ratings yet
Moment of Inertia
11 pages
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
1683044825934
PDF
1683044825934
JavaQbank V2
PDF
JavaQbank V2
Mod 3
PDF
Mod 3
Oop Concept
PDF
Oop Concept
Adobe Scan Nov 06, 2023
PDF
Adobe Scan Nov 06, 2023
Java Focused Short
PDF
Java Focused Short
Exam Java
PDF
Exam Java
Chapter Five
PDF
Chapter Five
Java
PDF
Java
Object-Oriented Programming With Java 7541-880
PDF
Object-Oriented Programming With Java 7541-880
Oops 03
PDF
Oops 03
Unit 3 - Relationships
PDF
Unit 3 - Relationships
Dashrath Nandan Java (Unit1) Notes - Alasso
PDF
Dashrath Nandan Java (Unit1) Notes - Alasso
UNIT:1 Þashath: A Pupiam
PDF
UNIT:1 Þashath: A Pupiam
Non Primitive Typecasting
PDF
Non Primitive Typecasting
Java A1
PDF
Java A1
Adobe Scan Jul 01, 2024
PDF
Adobe Scan Jul 01, 2024
12_Aruna_assignment 2 java
PDF
12_Aruna_assignment 2 java
Java Part 2
PDF
Java Part 2
OOP (Imp)
PDF
OOP (Imp)
Unit 3 - Programs
PDF
Unit 3 - Programs
Abstraction&Multiple Inheritance
PDF
Abstraction&Multiple Inheritance
Week 5
PDF
Week 5
Concept Programs - Docx 1
PDF
Concept Programs - Docx 1
Inheritance
PDF
Inheritance
DocScanner 30 Sept 2024 2 33 PM
PDF
DocScanner 30 Sept 2024 2 33 PM
CPP OOPS Module 5
PDF
CPP OOPS Module 5
Chapter 3 - Inheritance and Polymorphism
PDF
Chapter 3 - Inheritance and Polymorphism
JAVA Development: Inheritance, Interfaces, Abstract, Polymorphism
PDF
JAVA Development: Inheritance, Interfaces, Abstract, Polymorphism
JavaProgramming_Lecture04
PDF
JavaProgramming_Lecture04
Java CheatSheet
PDF
Java CheatSheet
Oop Concept in Java
PDF
Oop Concept in Java
Java
PDF
Java
Lecture 4.Part1
PDF
Lecture 4.Part1
Unit 5
PDF
Unit 5
Untitled document (1)
PDF
Untitled document (1)
BCS306A-module 3,4,5 3rd sem
PDF
BCS306A-module 3,4,5 3rd sem
Lab 05
PDF
Lab 05
1SG19IS043 - Karthik Bharadwaj.P - OOC
PDF
1SG19IS043 - Karthik Bharadwaj.P - OOC
OOPJ All 5 Units Ninad
PDF
OOPJ All 5 Units Ninad
Inheritance
PDF
Inheritance
C++@UNIT-IV
PDF
C++@UNIT-IV
Notes (27Sept2024(
PDF
Notes (27Sept2024(
JPR Question Bank_For_PTT1 (1)
PDF
JPR Question Bank_For_PTT1 (1)
Elective
PDF
Elective
135 Week 8
PDF
135 Week 8
Unit 2 Java
PDF
Unit 2 Java
C++ Assignment 2
PDF
C++ Assignment 2
Chap 11
PDF
Chap 11
Object and Class Example: Main Within The Class
PDF
Object and Class Example: Main Within The Class
CHAPTER 3 Inheritance
PDF
CHAPTER 3 Inheritance
Unit 2 Java
PDF
Unit 2 Java
Inheritance 1
PDF
Inheritance 1
95712C Lecture Notes Wednesday, September 29, 2004: 1. Stringtokenizer Class
PDF
95712C Lecture Notes Wednesday, September 29, 2004: 1. Stringtokenizer Class
la practice
PDF
la practice
CSC584 Enterprise Programming: Chapter 1 - Review of Object-Oriented Programming
PDF
CSC584 Enterprise Programming: Chapter 1 - Review of Object-Oriented Programming
MCA Java Programming 04(2)
PDF
MCA Java Programming 04(2)
PPT
PDF
PPT
SCR
PDF
SCR
OS-assignment-1
PDF
OS-assignment-1
SFH Previous Year Question Paper
PDF
SFH Previous Year Question Paper
Program11
PDF
Program11
CAED Lab Prac.
PDF
CAED Lab Prac.
Indian Constitution 2
PDF
Indian Constitution 2
Python Basics
PDF
Python Basics
Module-1 Sensors
PDF
Module-1 Sensors
Moment of Inertia
PDF
Moment of Inertia