The document discusses various Java concepts like abstract classes, interfaces, exceptions, threads, strings, input/output, applets, layout managers, swing components, and menus. It provides questions with multiple choice answers on these topics along with explanations for some answers. Key points covered include the syntax for abstract classes, implementing Runnable to create a thread, string concatenation vs assignment, vector size allocation, switch case fall-through behavior, and string and object passing.
1. Introduction to MATLAB and programming
2. Workspace, variables and arrays
3. Using operators, expressions and statements
4. Repeating and decision-making
5. Different methods for input and output
6. Common functions
7. Logical vectors
8. Matrices and string arrays
9. Introduction to graphics
10. Loops
11. Custom functions and M-files
This is the slides for the data science workshop at CDIPS, UC Berkeley on 06-28-2017. It is about general machine learning with a focus on scikit-learn. You can find all the related material: https://github.com/qingkaikong/20170628_ML_sklearn
1. Introduction to MATLAB and programming
2. Workspace, variables and arrays
3. Using operators, expressions and statements
4. Repeating and decision-making
5. Different methods for input and output
6. Common functions
7. Logical vectors
8. Matrices and string arrays
9. Introduction to graphics
10. Loops
11. Custom functions and M-files
This is the slides for the data science workshop at CDIPS, UC Berkeley on 06-28-2017. It is about general machine learning with a focus on scikit-learn. You can find all the related material: https://github.com/qingkaikong/20170628_ML_sklearn
In this chapter we will learn about arrays as a way to work with sequences of elements of the same type. We will explain what arrays are, how we declare, create, instantiate and use them. We will examine one-dimensional and multidimensional arrays. We will learn different ways to iterate through the array, read from the standard input and write to the standard output. We will give many example exercises, which can be solved using arrays and we will show how useful they really are.
Доклад рассказывает об устройстве и опыте применения инструментов динамического тестирования C/C++ программ — AddressSanitizer, ThreadSanitizer и MemorySanitizer. Инструменты находят такие ошибки, как использование памяти после освобождения, обращения за границы массивов и объектов, гонки в многопоточных программах и использования неинициализированной памяти.
Mining Source Code Improvement Patterns from Similar Code Review WorksYuki Ueda
Yuki Ueda, Takashi Ishio, Akinori Ihara, and Kenichi Matsumoto, "Mining Source Code Improvement Patterns from Similar Code Review Works", In Proc. 13th International Workshop on Software Clones (IWSC’19), 2019
this is good question set for CCAT exam and alos for CCEE
for more details please visit
http://acts.cdac.in
http://cdacguru.wordpress.com
http://fb.com/cdacguru
The aptitude test consisted tricky questions on core subjects of CSE like C , C++, Java ,Data Structures, Database, Computer Networks, Theory of Computation.
Programs are complete in best of my knowledge with zero compilation error in IDE Bloodshed Dev-C++. These can be easily portable to any versions of Visual Studio or Qt. If you need any guidance please let me know via comments and Always Enjoy Programming.
In this chapter we will learn about arrays as a way to work with sequences of elements of the same type. We will explain what arrays are, how we declare, create, instantiate and use them. We will examine one-dimensional and multidimensional arrays. We will learn different ways to iterate through the array, read from the standard input and write to the standard output. We will give many example exercises, which can be solved using arrays and we will show how useful they really are.
Доклад рассказывает об устройстве и опыте применения инструментов динамического тестирования C/C++ программ — AddressSanitizer, ThreadSanitizer и MemorySanitizer. Инструменты находят такие ошибки, как использование памяти после освобождения, обращения за границы массивов и объектов, гонки в многопоточных программах и использования неинициализированной памяти.
Mining Source Code Improvement Patterns from Similar Code Review WorksYuki Ueda
Yuki Ueda, Takashi Ishio, Akinori Ihara, and Kenichi Matsumoto, "Mining Source Code Improvement Patterns from Similar Code Review Works", In Proc. 13th International Workshop on Software Clones (IWSC’19), 2019
this is good question set for CCAT exam and alos for CCEE
for more details please visit
http://acts.cdac.in
http://cdacguru.wordpress.com
http://fb.com/cdacguru
The aptitude test consisted tricky questions on core subjects of CSE like C , C++, Java ,Data Structures, Database, Computer Networks, Theory of Computation.
Programs are complete in best of my knowledge with zero compilation error in IDE Bloodshed Dev-C++. These can be easily portable to any versions of Visual Studio or Qt. If you need any guidance please let me know via comments and Always Enjoy Programming.
Exam
Name___________________________________
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
1) Analyze the following program fragment:
int x;
double d = 1.5;
switch (d) {
case 1.0: x = 1;
case 1.5: x = 2;
case 2.0: x = 3;
}
1)
A) The switch control variable cannot be double.
B) The program has a compile error because the required break statement is missing in the
switch statement.
C) The program has a compile error because the required default case is missing in the switch
statement.
D) No errors.
2) Analyze the following code:
boolean even = false;
if (even = true) {
System.out.println("It is even!");
}
2)
A) The program runs fine, but displays nothing.
B) The program runs fine and displays It is even!.
C) The program has a runtime error.
D) The program has a compile error.
3) What is the printout of the following switch statement?
char ch = 'a';
switch (ch) {
case 'a':
case 'A':
System.out.print(ch); break;
case 'b':
case 'B':
System.out.print(ch); break;
case 'c':
case 'C':
System.out.print(ch); break;
case 'd':
case 'D':
System.out.print(ch);
}
3)
A) abc B) abcd C) ab D) aa E) a
1
4) The order of the precedence (from high to low) of the operators +, *, &&, ||, & is: 4)
A) *, +, &, &&, ||
B) *, +, &&, ||, &
C) &&, ||, &, *, +
D) &, ||, &&, *, +
E) *, +, &, ||, &&
5) The statement System.out.printf("%10s", 123456) outputs ________. (Note: * represents a space) 5)
A) ****123456 B) 12345***** C) 123456**** D) 23456*****
6) The following code displays ________.
double temperature = 50;
if (temperature >= 100)
System.out.println("too hot");
else if (temperature <= 40)
System.out.println("too cold");
else
System.out.println("just right");
6)
A) too cold B) too hot
C) too hot too cold just right D) just right
7) Which of the following code displays the area of a circle if the radius is positive? 7)
A) if (radius >= 0) System.out.println(radius * radius * 3.14159);
B) if (radius != 0) System.out.println(radius * radius * 3.14159);
C) if (radius > 0) System.out.println(radius * radius * 3.14159);
D) if (radius <= 0) System.out.println(radius * radius * 3.14159);
8) ________ is the code with natural language mixed with Java code. 8)
A) A flowchart diagram B) Java program
C) Pseudocode D) A Java statement
9) Analyze the following code:
if (x < 100) && (x > 10)
System.out.println("x is between 10 and 100");
9)
A) The statement compiles fine.
B) The statement has compile errors because (x<100) & (x > 10) must be enclosed inside
parentheses and the println(…) statement must be put inside a block.
C) The statement compiles fine, but has a runtime error.
D) The statement has compile errors because (x<100) & (x > 10) must be enclosed inside
parentheses.
10) In Java, the word true is ________. 10)
A) same as value 1 B) same as value 0
C) a Boolean literal D) a Java keyword
2
11) How many time ...
Name _______________________________ Class time __________.docxrosemarybdodson23141
Name: _______________________________ Class time: __________
Prewriting Instructions for Paper 2 (Final Paper due 4/22)
1. Your choices for Paper 2 are posted on blackboard and also listed below.
2. Choose 1 of these paper options. Notice that each choice also mentions the type of paper (comparison, etc.) My paper choice is: _________________________: paper type: _______________.
3. Read the related essay(s) in your Research and Composition textbook.
4. Thursday: write a tentative thesis for paper 2 (one sentence): ______________________________________________________________________________________________________________________________________________________________________________________________________________________.
5. Thursday: write 5 questions that you will need to answer through research to write this paper (for ex. What is the divorce rate for 2012?) Write legibly please.
1.
2.
3.
4.
5.
6. Thursday: go to the library and use the databases to locate at least three sources that will likely give you the information to answer the five questions above. At least one should be a book, at least one should be a database article. In addition, you may use your textbook, internet, or even refer to a film. Write down the all of the information about each source. You will need this information for a works cited page later or to locate the article and book again. You do not need to answer the questions right away, but if you do find the answers, take notes or make a copy of the source.
Source 1: ____________________________________________________________________________________________________________________________________________________________
Source 2: ____________________________________________________________________________________________________________________________________________________________
Source 3: ____________________________________________________________________________________________________________________________________________________________
7. Have any new questions come to mind? What are they? Write them here:
8. Have you revised your thesis? What is it? ___________________________________
_____________________________________________________________________.
9. Write a tentative first paragraph to paper 2 (this includes your thesis):
10. Turn this in Tuesday 3/25 in exchange for your last Q exercise, M&M Color Distribution.
***You need this prewriting exercise completed to receive your instructions and data for this last Q exercise and parts of this exercise will count for your attendance in a week or so.
See next page
Writing Assignment 2 Choices due on or before 4/22
Here are your choices for Writing Assignment 2 due 4/22. Additional research is required for all choices. Two visuals, tables or figures, are required. Your paper will be in MLA format with a works cited page. This paper is approximately 5 pages including a works cited page.
1. Read the essays in Chapter 8. Go .
1. • Which of the following is correct syntax for an Abstract class ?
(a) abstract double area() { }
(b) abstract double area()
(c) abstract double area();
(d) abstract double area(); { }
ANS: (c)
• A class can be converted to a thread by implementing the interface __________
(a) Thread
(b) Runnable
ANS: (b)
• What is the output of following block of program ?
boolean var = false;
if(var = true) {
System.out.println("TRUE");
} else {
System.out.println("FALSE");
}
(a) TRUE
(b) FALSE
(c) Compilation Error
(d) Run-time Error
ANS: (a)
EXPLANATION: The code compiles and runs fine and the 'if' test succeeds because 'var' is set to
'true' (rather than tested for 'true') in the 'if' argument.
• A Vector is declared as follows. What happens if the code tried to add 6 th element to
this Vector new vector(5,10)
(a) The element will be successfully added
(b) ArrayIndexOutOfBounds Exception
2. (c) The Vector allocates space to accommodate up to 15 elements
ANS: (a) and (c)
EXPLANATION: The 1 st argument in the constructor is the initial size of Vector and the 2 nd
argument in the constructor is the growth in size (for each allocation)
This Vector is created with 5 elements and when an extra element (6 th one) is tried to be
added, the vector grows in size by 10.
• What is the output of following piece of code ?
int x = 2;
switch (x) {
case 1:System.out.println("1");
case 2:
case 3:System.out.println("3");
case 4:
case 5:System.out.println("5");
}
(a) No output
(b) 3 and 5
(c) 1, 3 and 5
(d) 3
ANS: (b)
• Which of the following 2 methods executes faster ?
class Trial {
String _member;
void method1() {
for(int i=0;i<2048;i++) {
_member += "test";
}
}
void method2() {
3. String temp;
for(int i=0;i<2048;i++) {
temp += "test";
}
_member = temp;
}
}
(a) method1()
(b) method2()
(c) Both method1() and method2() takes same time for execution
ANS: (b)
Accessing method variables requires less overhead than accessing class variables.
• Integer.parseInt("12a") returns
(a) Exception
(b) 1
(c) 0
(d) -1
ANS: (a)
• By default, Strings to functions are passed using the method
(a) Call by Value
(b) Call by Reference
(c) Strings cannot be passed to function
ANS: (b)
String is a class defined in java.lang and in java all classes are passed by reference.
4. • What is the output of following program ?
class Test {
public static void main(String args[]) {
for(int i=0;i<2;i++) {
System.out.println(i--);
}
}
}
(a) Goes into infinite loop
(b) 0,1
(c) 0,1,2
(d) None
ANS: (a)
• It is the reference to a class that extends THREAD. Then how to suspend the execution
of this thread?
(a) t.yield()
(b) yield(t)
(c) yield()
(d) yield(100) where 100 is the milli seconds of time
• How many String objects are created by the following statements ?
String str = " a+b=10 ";
trim(str)
str.replace(+,-);
(a) 1
(b) 2
(c) 3
(d) 4
5. ANS: (c)
• Cleaning operation in Java is done in the method
(a) finally()
(b) finalize()
(c) final()
• If we want to read a very big text file with so many mega bytes of data, what shall we
use ?
(a) FileInputStream
(b) InputStreamReader
• What code, if written, below the (//code here) will display 0.
class Test {
public static void main(String argv[]) {
int i=0;
//code here
}
}
(a) System.out.println(i++)
(b) System.out.println(i+'0')
(c) System.out.println(i--)
(d) System.out.println(i)
ANS: (a),(c),(d)
The option (b) displays the ASCII value of '0'. So, the output in this case is: 48
• Which one of the following about Applet is true? (Choose all that applies)
a. Applets are executed by console based-java run-time interpreter.
b. Applets are executed by a Web Browser
c. Applets are executed by an Applet Viewer
6. d. None of the Above
• In applets which method is used to allocate memory to the components?
a) start()
b) stop()
c) init()
d) destroy()
• While executing applets in browser the tag specified in the HTML browser is
a) <html></html>
b) <appletviewer></appletviewer>
c) <applet></applet>
d) <xml></xml>
• Which of the following method is used to retrieve the base URL of the applet
a) getAppletInfo()
b) getDocumentInfo()
c) getDocumentBase()
d) getCodeBase()
• The method used in applet to display image in the status bar is
a) showInfo()
b) showStatus()
c) dialogStatus()
d) dialogInfo()
• The method used to dynamically specify the size to the applet is
7. a) pack()
b) size()
c) resize()
d) height, width
• Expand AWT
a) Applet Windows Tool Kit.
b) Applications Windows Tool Kit
c) Abstract Windows Tool Kit
d) None of the Above
• Which one of the following is an Abstract Class?
a. Graphics
b. Color
c. Menu
d. Font
e. None of the above
• Which of the following is the default Layout Manager in Java?
a. Border Layout Manager
b. Flow Layout Manager
c. Grid Bag Layout Manager
d. Card Layout
e. None of the Above.
• In which Layout Manager extra space is placed in the Center region ?
a) Border Layout Manager
8. b) Flow Layout Manager
c) Grid Bag Layout Manager
d) Card Layout
e) None of the Above.
• In which Layout Manager the container is divided into equally-sized
rectangles, and one components is placed in the rectangles
a. Border Layout Manager
b. Flow Layout Manager
c. Grid Bag Layout Manager
d. Card Layout
e. Grid Layout
f. None of the Above.
• Which of the following are the features of swing components?
a. Lightweight
b. Portable
c. Look & Feel
d. All the above
• MVC stands for
a. Model View Controller
b. Model View Container
c. Meta View Container
9. d. Model Volatile Container
• Swing components are categorized into
a. Applets and Applications
b. Frames and Panels
c. Containers and Controls
d. none of above
• Window Event can be activated on the containers like
a) JFrame
b) JPanel
c) Component
d) Controls
• The method used to alter the displayed set of characters in the
components like password field is
a. setText()
b. setLabel()
c. echoChar()
d. setEchoChar()
• The method used to add element in the combobox is
a. addItem()
b. addElement()
c. addValue()
d. setElement()
• Which methods is used to separate different menu items in the menu bar