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)
16 views
Programming-2 Sheets
Sheets
Uploaded by
amrt6958
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Programming-2 Sheets For Later
Download
Save
Save Programming-2 Sheets For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
16 views
Programming-2 Sheets
Sheets
Uploaded by
amrt6958
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Programming-2 Sheets For Later
Carousel Previous
Carousel Next
Save
Save Programming-2 Sheets For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 9
Search
Fullscreen
See: A GridLayout B. FlowLayout C. _ BorderLayout)p, 21. When a Java application starts, what 1s the name of the method that 1s executed? QQ _maim B) os Cc) begin D) Main, 2 TeatencTosed between this and the end of line ts ignored by the compiler one Cc) 0 mn 2S Writes themame of the file declaring the class namedMyClass? A) MyClass ©) MyClass.class B) myelass java D) MyClass java > i __ MyClass 24. Ain) _ is acollection of code that has been progi2mmed and translated by someone else, ready for use in your program. A) method ©) rameter B) class Dy library > 25 pen a moran consists of one or more of these fundamental building blocks. 7 cla c) applet B) CPU D) parameter 26. What is the name of the file that contains the Java source code for the class BankAccount? A) BankAccount c) BankAccount.class a Bank Account java_) D) BankAccount.txt ad Contains sequences of instructions to perform a particular task. A) parameter 6) variable B) label 28. The Java compiler ignores any text between A and * ©) {* and *} Gt D) Mand |) or 29. What term is used to refer to a sequence of characters enclosed in quotation marks? 52 inh oO comment ae le © he (eee) B Object D) vari 30. What is the output of the following Java statement? "System. out printIn(" A 10 c. 4 D Bas 31. What is the output of the following Java statement? System.out printin(4 + 6); A. 4+6 B 4 D. 46 32. Which statement is true about a Java program? A) Java forces the programmer to use a particular layout for readability. » B) Java requires that at most one statement appear on one line. & Cs ‘The first method that is executed in a Java program is called Main. * Cee 33. The Java comiptler translates source code into what type of file? A) document B) object D) text 34. Identify and correct re errors in each of the following statements: 1. if(e<7, VERES System.out. ody "cis less than 7" ), 2. if(e=27) 1FUC >= F) System.out printin( "c is equal to or greater than 7" ), ‘write a complete program that calculates and prints the product of three integers. (Note by scanner or JOptionPane classes). ‘ 36. How many times does the following loop execute? int i= 0, > CamScanner + Lia > g.unallCamScanner 4 Lis &sucall‘ Dt on the following code, which suse the 2 code, which of the follo 200 wing statements sets the frame to a width of 400 and a setVisible(); IGHT = 200; JFrame frame = (FRAME _WIDTH, FRAME. HIGHT) « AME WIDTH FRAM D. frame setSize(FRAME_HE 36. Eas “ie cae statement, which of the following statements sets the ile ofthe fame SFra. A. frame title = ""An Empty Frame’ B. frame setTitle(JFrame EMPTY), _C. frame addTitle("" An Empty Frame’ D._ frame setTitle(”*An Empty Frame); 37, What is the nickname for the graphical user interface library in Java? rw. Applet _C. JComponent B. GUI CD. Swing 38. What does an object store its data in? ————— A. files CC. instance vari ifiers B. methods D. accessspeci 39. Which one of the following statements can be used to convert a string str to a double” a) double n = str.parseDouble();* b) double n = Integer. parseDouble(str); @ double n = Double parseDouble(str); d) double n = double parseDouble(str); 2 3 40. What is the value of Math.pow(2, 3)? a)50 (os) b)60 90 41. Given two method definitions, tell which of the two methods is invoked for: #1: public static double m(double x, double y) #2: public static double m(int x, double y) double z= m(4, 4.5); Zz double z = m(5, 4); Zz ( 1 double z= m(4.5, 5.4), double z= m(4.5, 4): 42, Show the output of the following program public class Test { public static void maualsiringil args), { int number = — Pre mihi ve int (J numbers = new int [1]; —» reherenc-e m(number, numbers); System.out.printin("number is "+ number +" and numbers|0] is"+ —numbers|0|); } public static void m(int x, int [] y) { output x=12; — y[0]=13; xt, ih number's 0 and numbers] 15 CamScanner 4 Lis & sucall| 45, What are the features of an Object driented Programming A) Inheritance B) Encapsulation 44, What are the feature 'A) Methods B) Variables 45, The class that is A) Subclass 46, es reused using Inheritance in Java? being inherited or su ss that inherits an alread B) Superclass 447, Java language supports le Inheritance in type of inheritance y defined class is called _ i (OOP)? C) Polymorphism D) All the above €) Constants D) All the above ) \ classed is called Conall (3 aie JIB eS class A { public AQ) { System.out printin( "The default constructor of A is invoked"), He class B extends A { public BO { super )s System. out printin( The default constructor of B is invoked"); y public class C { public static void main(String] ares) { Bb=new BO; } | public static void main(Stringt] public class Test { args)\ Aa=new AQ; a.p(10); a.p(10.0), Hs class B { public void p(double i) { ‘System out printIn(i *2); Mb class AextendsB{ overt oe public void p(double i) { System.out.println(i); } class Animal { String name = "animal", String makeNoise() { return "generic noise", } } class Dog extends Animal{ String name = "dog", String makeNoise() { return "bark"; } } public class Test { public static void main(String|] args) { ‘Animal an = new Dog(), .+""-+an. makeNoise()); 7 class Test { private static int x; = ° private int y=2; public Test(){ xt yrh } public static void main(String{] args){ 3 Test ol =new Test(); “=! 19° Test 02 =new Test); **2 -3 3 System out printin("y= "+02." x= "+02.x); ‘System.out. printIn(an.name jin Lb h ‘49. Complete the following sentences: 1. Keyword--CL E14 requests memory from the system to store an object, then calls the corresponding class’s constructor to initialize the object. 2, Methods—————— sysiem-ow- print Yo sy Sem. out - Prete ere na display information in a commani \d window. Lc CamScanner 4 Lis a suueall| Name: dec: 42, Which of the following constructs a Circle of radius 3, assuming the construction parameter is the rag, value? A. Circle(3).new C. new Cirele(3) CB__new Circle(3) > D. Circle(3) 43. Which statement declares a variable that references a Circle of radius 3? A. Circle c= Circle(3) C. Circle ¢.new.Ci D. ¢.Circle(3); “44, Which siatement calls a constructor with no construction parameters? C. Circle ¢ = new Circle; 3); B.A call to a constructor must haye construction D. Circle ¢ = Circte() parameters, 45, What terminology describes a method that returns information about its implicit parameter sniioes yet change theparameter’s internal data? ger mahed A_mutator C. void D. public 46. What terminology describes a method that modifies the | data of its implicit parameter? A. public C. mutator) sey wrenno B. void ‘accessor 4 20.4 is a collection of classes with a related purpose. C. method B. import D. collection 28. To use a class in another package you need to__it A. export C._tewrite B. overload 29. Which package is automatically imported in any Java program? A. java system C. javalanguage D. java.util 30. Which class is part of the java.lang package? A. Rectangle CC String ) System B. PrintStream D. Cirele 31. Assuming the following Java statement. Circle cl = new Circle(3); What does the variable cl store? ‘A. The constructed object itself. B_ A reference to the Circle cl C_ A reference to the memory location of the constructed obj D. The numeric value 3 ane. 4 32. What is the output of the sannR Er C2-rodtus = iy Circle cl =new Circle(3); Circle e2= el; cl.setRadius(4), or ystem out printin(c2.getRadius()); ae C6 Ww? ee ee 33. What is the output of the following code:Cirele cl = new Circle(3), Circle c2 = new Circle(3); cl setRadius(4); System.out printin(c2.getRadius()); C6 . 8 D4 34. Complete this code fragment to ensure that the frame is shown: came frame = new JFrame(); (© tame sible) Sac mean CamScanner 4 Lis & sucall=Set: sna variable x declared as a double and initialized, show the . shovy the java code to cast and store : ble y which is defined as a short, oo Lott er yw tS ohana Ng algo x nto.a va Write a java statement can be used to convert a string str to a double? 4 S. What is the statement to display the message “Hello world" in a message dialog box? | 6. Convert the following java statement to Conditional Operator (?:) : if (x > 0) 7 4 ‘ ye (x0) L ; else a Tats enh SphonPane «show! z % 7. What does the following state . snt do? for (; ) {do something; . 8. To returns the square root of 2 ».sing method V5. or 9. To rounded up the number to iis nearest integer using method | 10. The output from invoking Math.random() is_MNcarn yah 11. The default value ofa data field is_\)|__ for a reference type Codes (UZ Show one line of Java code that declares and initializes an array of type integer with exactly 4 elements nap dol G whose values are 97, 33, 44, and 12, in order. —> Write a method that retums the sum of all the elements in a specified column in a matrix using the following header: public static doublesumColumn(double{][] m, intcolumnindex) Write 2 test program that reads a 3-by-4 matrix and displays the sum of each column 1, Find the index of the smallest element) Write a method that retums the index of the smallest element in an array of integess. If the number of such elements is greater than 1, return the smallest index. Use the following header: public static int indexOfSmallestElement(double{] array) Write a test program that prompts the user to enter ten numbers, invokes this method to retur the index of the smallest clement, and displays the index he area of a rectangle by creating a class named ‘Area’ taking the values ( Write a program to print tl ceadth as parameters of its constructor and having a'method named ‘tetumArea’ which of its length and breadth returns the area of the rectangle. Length and breadth of rectangle are entered through keyboard J Create a class named Person that holds the following fields: two String for the person's first and last name and a LocalDate object for the person’s birthdate. Create a class named Couple that contains two ‘ors for each class that accept parameters for each field and provide get passes each to a method Person objects. Provide construct methods for each field. Then write a program that creates two objects and in turn that displays all the details. (Employee Class) Create a class called Employee that includes three instance variables—a first name (type String), a last name (type String) and a monthly salary (double). Provide a constructor that initializes the three instance variables. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its value. Write a test application named Employee Test that demonstrates class Employee's capabilities. Create two Employee objects and display each object’s yearly salary. Then give each Employee a 10% raise and display each Employee's yearly salary again A ‘A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write an application that reads in a five-digit integer and determines whether it’s a palindrome, If the number is not five digits ong, display an error message and allow the user to enter a new value. 8. Write a Java program to display the employee id, age, first name and last name using JDBC connectivity. 7 CamScanner 4 Lis a suueallSec = The program connects to 4 local MySQL database and displays all elements in which salary m nore A than 100008 6 Waite java method for find summation of ragged array and max number (JZ lava Program to Find Area of Square, Rectangle and Circle using Method Overloading IZ Write a recursive method for computing a factorial factorialin), given n. The test program prompts the Name: user fo enter n Implement a class named person and two subclasses of Person named Student and Employee. Mak o Faculty and Staff subviasses of Employee. A person has a name, address, phone number, and ‘aul address. A student has « class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, and date-hired. A faculty member has office hours and a rank. A staff member has a title. Override the toString method in each class to display the class name and the person's name, [hint: After implementation Draw the UML] Wal Write a program using swing components to find simple interest. Use text fields for inputs and output ‘Your program should display the result when the user presses a button. Simple Interest = (P x R x T)/100_ where P = Principal Amount, R = Rate of interest, T = Time (years) ter of a JPanel The innermost circle should have a radius of 10 id have a radius 10 pixels larger than the previous one. Begin by UZ Draw 12 concentric circles in the cen ircle, move up one radius and to the left pixels, and each successive circle shoul finding the center of the JPanel. To get the upper-left comer of a ci ‘one radius from the center, The width and height of the bounding rectangle are both the same circle’s diameter (i.e., twice the radius). 16. Write a Java Student class which has three private data members name. id, and score. The student's name ‘The score is an integer between 0 and 100. Then as the and id are all strings of no more than 10 characters. constructor and getter/setter for each data member. finally, method for display the highest score and the lowest score. Write UML for student class in the } inst page IW UX CamScanner 4 Lis a suueall
You might also like
KISA Prep - Computer Applications 2025
PDF
90% (10)
KISA Prep - Computer Applications 2025
8 pages
Diagnostic Test Java Programming
PDF
No ratings yet
Diagnostic Test Java Programming
4 pages
Solved Java
PDF
No ratings yet
Solved Java
28 pages
1z0-808 Dumps
PDF
0% (1)
1z0-808 Dumps
199 pages
Java Programming Moc Test
PDF
No ratings yet
Java Programming Moc Test
31 pages
Exercises
PDF
No ratings yet
Exercises
14 pages
Java
PDF
No ratings yet
Java
4 pages
prefinal-2025
PDF
No ratings yet
prefinal-2025
6 pages
64 Java Questions For Any Job Interview
PDF
No ratings yet
64 Java Questions For Any Job Interview
19 pages
Set 3
PDF
No ratings yet
Set 3
7 pages
PreBoard Comp 2024
PDF
No ratings yet
PreBoard Comp 2024
4 pages
Solution Manual - Electronic Devices and Circuit Theory 10th Edition
PDF
No ratings yet
Solution Manual - Electronic Devices and Circuit Theory 10th Edition
13 pages
Oop
PDF
No ratings yet
Oop
20 pages
Final Java 2023
PDF
No ratings yet
Final Java 2023
11 pages
CMS PRE-BOARD Question paper Class 10th Computer
PDF
No ratings yet
CMS PRE-BOARD Question paper Class 10th Computer
9 pages
Icse 10 2024
PDF
No ratings yet
Icse 10 2024
4 pages
Java Questions 2
PDF
100% (1)
Java Questions 2
11 pages
Java
PDF
No ratings yet
Java
43 pages
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis - Download Instantly To Experience The Full Content
PDF
100% (13)
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis - Download Instantly To Experience The Full Content
40 pages
Comp 1510 Mid Sample
PDF
No ratings yet
Comp 1510 Mid Sample
6 pages
Java Practice Test 1
PDF
No ratings yet
Java Practice Test 1
6 pages
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis - Full Version Is Available For Instant Download
PDF
100% (5)
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis - Full Version Is Available For Instant Download
42 pages
Anand Nagar Ms Monika Tripathi CLASS X CFQ ANANDNAGAR
PDF
No ratings yet
Anand Nagar Ms Monika Tripathi CLASS X CFQ ANANDNAGAR
7 pages
Java Excersie2
PDF
No ratings yet
Java Excersie2
21 pages
Chapter 2 Elementary Programming
PDF
100% (1)
Chapter 2 Elementary Programming
21 pages
Java MCQ
PDF
No ratings yet
Java MCQ
7 pages
Question Bank
PDF
No ratings yet
Question Bank
20 pages
Java MCQ
PDF
100% (1)
Java MCQ
13 pages
MCQs JAVA
PDF
No ratings yet
MCQs JAVA
42 pages
Object Oriented Programming and Java (MC221) April 2006
PDF
No ratings yet
Object Oriented Programming and Java (MC221) April 2006
22 pages
Logical Que 1
PDF
No ratings yet
Logical Que 1
10 pages
Java MCQ
PDF
No ratings yet
Java MCQ
56 pages
Niit Java Exam
PDF
No ratings yet
Niit Java Exam
9 pages
ElectiveSubject3WebDevelopmentusingJavaQB PDF
PDF
No ratings yet
ElectiveSubject3WebDevelopmentusingJavaQB PDF
143 pages
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis download
PDF
100% (1)
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis download
45 pages
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis PDF Download Full Book with All Chapters
PDF
100% (6)
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis PDF Download Full Book with All Chapters
33 pages
Java Multiple Choice Questions
PDF
No ratings yet
Java Multiple Choice Questions
22 pages
Integra micro Third section(java)
PDF
No ratings yet
Integra micro Third section(java)
5 pages
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis - Read Now With The Full Version Of All Chapters
PDF
100% (6)
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis - Read Now With The Full Version Of All Chapters
45 pages
1735412399
PDF
No ratings yet
1735412399
15 pages
Object Oriented Programming and Java (MC221) January 2006
PDF
No ratings yet
Object Oriented Programming and Java (MC221) January 2006
18 pages
Examen Java Programmer I
PDF
No ratings yet
Examen Java Programmer I
118 pages
Java MCQ Ans
PDF
No ratings yet
Java MCQ Ans
8 pages
II-CIA - Java Programming - MCQs - 03.03.2023
PDF
No ratings yet
II-CIA - Java Programming - MCQs - 03.03.2023
17 pages
Java Doeacc MCQ
PDF
No ratings yet
Java Doeacc MCQ
15 pages
Preboard 1 x
PDF
No ratings yet
Preboard 1 x
6 pages
Exercises
PDF
100% (1)
Exercises
15 pages
Page 1 of 17
PDF
No ratings yet
Page 1 of 17
17 pages
Java Master
PDF
No ratings yet
Java Master
138 pages
CoreJava QuestionPaper
PDF
No ratings yet
CoreJava QuestionPaper
15 pages
Biñan City Senior High School - San Antonio Campus
PDF
No ratings yet
Biñan City Senior High School - San Antonio Campus
4 pages
Class 10 Key
PDF
No ratings yet
Class 10 Key
5 pages
Maulana Abl:.Il - Kalam Azad University of Technology, West Bengal
PDF
No ratings yet
Maulana Abl:.Il - Kalam Azad University of Technology, West Bengal
2 pages
Javac
PDF
No ratings yet
Javac
9 pages
Download Study Resources for Introduction to Java Programming Brief Version 10th Edition Liang Test Bank
PDF
100% (4)
Download Study Resources for Introduction to Java Programming Brief Version 10th Edition Liang Test Bank
35 pages
Sec 3 _Speech Recognition_intro
PDF
No ratings yet
Sec 3 _Speech Recognition_intro
14 pages
Sec 4_Audio Signal Acquisition_ Read&Write Wave_ Plot
PDF
No ratings yet
Sec 4_Audio Signal Acquisition_ Read&Write Wave_ Plot
12 pages
Problem Solving by Search
PDF
No ratings yet
Problem Solving by Search
14 pages
Solve the Sheet 12
PDF
No ratings yet
Solve the Sheet 12
4 pages
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
KISA Prep - Computer Applications 2025
PDF
KISA Prep - Computer Applications 2025
Diagnostic Test Java Programming
PDF
Diagnostic Test Java Programming
Solved Java
PDF
Solved Java
1z0-808 Dumps
PDF
1z0-808 Dumps
Java Programming Moc Test
PDF
Java Programming Moc Test
Exercises
PDF
Exercises
Java
PDF
Java
prefinal-2025
PDF
prefinal-2025
64 Java Questions For Any Job Interview
PDF
64 Java Questions For Any Job Interview
Set 3
PDF
Set 3
PreBoard Comp 2024
PDF
PreBoard Comp 2024
Solution Manual - Electronic Devices and Circuit Theory 10th Edition
PDF
Solution Manual - Electronic Devices and Circuit Theory 10th Edition
Oop
PDF
Oop
Final Java 2023
PDF
Final Java 2023
CMS PRE-BOARD Question paper Class 10th Computer
PDF
CMS PRE-BOARD Question paper Class 10th Computer
Icse 10 2024
PDF
Icse 10 2024
Java Questions 2
PDF
Java Questions 2
Java
PDF
Java
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis - Download Instantly To Experience The Full Content
PDF
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis - Download Instantly To Experience The Full Content
Comp 1510 Mid Sample
PDF
Comp 1510 Mid Sample
Java Practice Test 1
PDF
Java Practice Test 1
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis - Full Version Is Available For Instant Download
PDF
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis - Full Version Is Available For Instant Download
Anand Nagar Ms Monika Tripathi CLASS X CFQ ANANDNAGAR
PDF
Anand Nagar Ms Monika Tripathi CLASS X CFQ ANANDNAGAR
Java Excersie2
PDF
Java Excersie2
Chapter 2 Elementary Programming
PDF
Chapter 2 Elementary Programming
Java MCQ
PDF
Java MCQ
Question Bank
PDF
Question Bank
Java MCQ
PDF
Java MCQ
MCQs JAVA
PDF
MCQs JAVA
Object Oriented Programming and Java (MC221) April 2006
PDF
Object Oriented Programming and Java (MC221) April 2006
Logical Que 1
PDF
Logical Que 1
Java MCQ
PDF
Java MCQ
Niit Java Exam
PDF
Niit Java Exam
ElectiveSubject3WebDevelopmentusingJavaQB PDF
PDF
ElectiveSubject3WebDevelopmentusingJavaQB PDF
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis download
PDF
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis download
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis PDF Download Full Book with All Chapters
PDF
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis PDF Download Full Book with All Chapters
Java Multiple Choice Questions
PDF
Java Multiple Choice Questions
Integra micro Third section(java)
PDF
Integra micro Third section(java)
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis - Read Now With The Full Version Of All Chapters
PDF
Test Bank Starting Out with Java: Early Objects, 5/E Tony Gaddis - Read Now With The Full Version Of All Chapters
1735412399
PDF
1735412399
Object Oriented Programming and Java (MC221) January 2006
PDF
Object Oriented Programming and Java (MC221) January 2006
Examen Java Programmer I
PDF
Examen Java Programmer I
Java MCQ Ans
PDF
Java MCQ Ans
II-CIA - Java Programming - MCQs - 03.03.2023
PDF
II-CIA - Java Programming - MCQs - 03.03.2023
Java Doeacc MCQ
PDF
Java Doeacc MCQ
Preboard 1 x
PDF
Preboard 1 x
Exercises
PDF
Exercises
Page 1 of 17
PDF
Page 1 of 17
Java Master
PDF
Java Master
CoreJava QuestionPaper
PDF
CoreJava QuestionPaper
Biñan City Senior High School - San Antonio Campus
PDF
Biñan City Senior High School - San Antonio Campus
Class 10 Key
PDF
Class 10 Key
Maulana Abl:.Il - Kalam Azad University of Technology, West Bengal
PDF
Maulana Abl:.Il - Kalam Azad University of Technology, West Bengal
Javac
PDF
Javac
Download Study Resources for Introduction to Java Programming Brief Version 10th Edition Liang Test Bank
PDF
Download Study Resources for Introduction to Java Programming Brief Version 10th Edition Liang Test Bank
Sec 3 _Speech Recognition_intro
PDF
Sec 3 _Speech Recognition_intro
Sec 4_Audio Signal Acquisition_ Read&Write Wave_ Plot
PDF
Sec 4_Audio Signal Acquisition_ Read&Write Wave_ Plot
Problem Solving by Search
PDF
Problem Solving by Search
Solve the Sheet 12
PDF
Solve the Sheet 12